Nuget包管理器更新3.1.1.0出现故障。

21

我将Nuget包管理器更新到版本3.1.1.0后,打开任何项目都会出现错误消息: copy-item: cannot find path 'c:\users{username}\documents\visual studio 2015\projects{project name}\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\tools\lib\net45' because it does not exist ..... 在文件init.ps1中。

我发现传递给init.ps1的$installpath变量与旧的Nuget不同,实际上还附加了\tools子目录名称,这显然是不正确的,并导致了错误。

我如何影响这个$installpath参数或将Nuget降级到3.1.0?

我在一个全新安装的虚拟机中进行了双重检查,并得到了相同的结果:VS安装->正常,升级到Nuget 3.1.1->损坏。

环境:Windows 10德语版,Visual Studio 2015社区版英语版


1
我会在NuGet的GitHub网站上开一个问题,关于你所看到的问题。 - Matt Ward
在 GitHub 上开了一个问题:https://github.com/NuGet/Home/issues/1125#issuecomment-128503074。 - X-Mao
5个回答

31

不确定这是否能帮到其他人,但我在使用 Microsoft.CodeDom.Providers.DotNetCompilerPlatform 和 VS2015 时遇到了完全相同的错误。对我有用的解决方法是在“包管理器控制台”中执行以下操作:

Update-Package Microsoft.CodeDom.Providers.DotNetCompilerPlatform

保存,关闭并重新打开Visual Studio后,就没有错误了。对我来说,不需要编辑任何ps1文件。

顺便提一下。


我遗失了它所提到的“packages”文件夹。这是在强制关闭并恢复文档后发生的,所以@Tod Thomson的解决方案对我没用,但这个可以。 - Paul Totzke
2
DotNetCompilerPlatform.1.0.2 对我有用,因为在 VS 2015 中引用了 DotNetCompilerPlatform.1.0.0。我收到的错误是:_Join-Path:无法将“System.Object []”转换为参数“ChildPath”所需的类型“System.String”。指定的方法不受支持。位于 .... init.ps1:13 字符:57_,还有 _Join-Path:无法绑定参数“Path”,因为它为空... 在 init.ps1:14 字符:44_。 - SliverNinja - MSFT
1
多年后,我在使用VS 2019时遇到了同样的问题。这个方法解决了我的问题。 - user5151179

20

我也遇到了相同的错误(如下所示):

Copy-Item : Cannot find path 'C:\Development\GitHub\pd-tech-demo\backend\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\tools\lib\net45' because it does not exist.
At C:\Development\GitHub\pd-tech-demo\backend\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\tools\init.ps1:23 char:1
+ Copy-Item $libDirectory\* $binDirectory | Out-Null
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : ObjectNotFound: (C:\Development\...tools\lib\net45:String) [Copy-Item], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.CopyItemCommand

我更改了init.ps1文件中第10行的内容:

$libDirectory = Join-Path $installPath 'lib\net45'

至:

$libDirectory = Join-Path $installPath '..\lib\net45'

这个修复方法只在你再次恢复该包并且出现了问题的版本之前有效。

真正的解决方法是让软件包维护者更新他们的 init.ps1 副本。我会跟进并尝试看看是否可以完成这一点。:)


这是NuGet中的一个bug,请参见我下面的评论。 - Yishai Galatzer

2

我在包管理器控制台中遇到了同样的错误,最终在这个帖子中找到了解决方案。

正如错误信息所说,由于缺少...\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\tools\lib\net45目录,因此出现了问题。

由于某种原因,“lib”目录直接创建在“Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0”目录下?当我将“lib”目录移动到“tools”目录下并重新启动VS时,错误信息消失了。


2

这个问题已经被https://github.com/NuGet/Home/issues/1125跟踪。 我们正在与包所有者合作,看看他是否可以停止使用init.ps1来设置项目。这个过程不符合NuGet的指南,但我们还不确定是否有解决方法。


2
修复已经在进行中,它将成为3.1.2版本的一部分。 - Yishai Galatzer

0

我也遇到了这个错误。 将init.ps1的第10行更改为: 但这并没有起作用:

$libDirectory = Join-Path $installPath '..\lib\net45'

这是有效的:

$libDirectory = Join-Path $installPath '\lib\net45'

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接