21
votes

I updated Nuget package manager to version 3.1.1.0. After the update opening any project gives me the error message: 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 ..... in file init.ps1

I found $installpath variable given to init.ps1 differs from old nuget to actual in additionally appended \tools subdirectory name, which is obviously wrong and gives the error.

How can I influence this $installpath parameter or downgrade nuget to 3.1.0?

I double-checked this behaviour also in a fresh installed vm with the same result, VS installed -> ok, update to nuget 3.1.1 -> broken.

Environment: Windows 10 German, Visual Studio 2015 Community Edition English

5
I would open an issue on NuGet's GitHub site about the problem you are seeing.Matt Ward

5 Answers

30
votes

Not sure if this will help others, but I got the exact same error on VS2015 with Microsoft.CodeDom.Providers.DotNetCompilerPlatform and what fixed it for me was to do the following in the Package Manager Console:

Update-Package Microsoft.CodeDom.Providers.DotNetCompilerPlatform

Then after saving, closing and reopening VS, no more errors. No need to edit any ps1 files for me.

FWIW.

20
votes

I got the same error as well (as follows):

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

I changed line 10 of init.ps1 from:

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

to:

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

which fixes the problem (only until you restore the package again and you get the broken version).

The real fix is for the package maintainers to update their copy of init.ps1. I'll follow up and see if we can get that done. :)

2
votes

This issue is Tracked by https://github.com/NuGet/Home/issues/1125 we are also working with the package owner to see if he can move off using init.ps1 for setting up the project. This process does not follow the NuGet guidelines, but we are not sure if there is a workaround yet.

2
votes

I got the same error in Package Manager Console and eventually found this thread.

As the error message said, the packages ...\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\tools\lib\net45 directory is missing hence the problem.

The "lib" directory is created directly under "Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0" directory for some reason? When I moved the "lib" directory into "tools" directory, restart VS, error message gone.

0
votes

I also had this error. Changing line 10 of init.ps1 to: This did not work:

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

This did work:

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