Update-Package -reinstall or Uninstall-Package won't work for .NET Framework projects
See original GitHub issueTo repo: Visual Studio 2017, start a new .NET Framework Library project targeting .NET 4.5 or 4.0. Install Microsoft.SourceLink.Github from Package Manager Console. Build, get error
error : Unable to locate repository containing directory 'c:\scratch\ClassLibrary4\ClassLibrary4
which is fine, we don’t have github set up for this project yet.
But then if you call Update-Package -reinstall or Uninstall-Package, it would give errors like this:
PM> update-package -reinstall
Attempting to gather dependency information for multiple packages with respect to project 'ClassLibrary4', targeting '.NETFramework,Version=v4.5'
Gathering dependency information took 1.07 sec
Attempting to resolve dependencies for multiple packages.
Resolving dependency information took 0 ms
Resolving actions install multiple packages
Retrieving package 'Microsoft.Build.Tasks.Git 1.0.0-beta-62925-02' from 'nuget.org'.
Retrieving package 'Microsoft.SourceLink.Common 1.0.0-beta-62925-02' from 'nuget.org'.
Retrieving package 'Microsoft.SourceLink.GitHub 1.0.0-beta-62925-02' from 'nuget.org'.
Removed package 'Microsoft.SourceLink.GitHub 1.0.0-beta-62925-02' from 'packages.config'
Successfully uninstalled 'Microsoft.SourceLink.GitHub 1.0.0-beta-62925-02' from ClassLibrary4
Removed package 'Microsoft.SourceLink.Common 1.0.0-beta-62925-02' from 'packages.config'
Successfully uninstalled 'Microsoft.SourceLink.Common 1.0.0-beta-62925-02' from ClassLibrary4
Removed package 'Microsoft.Build.Tasks.Git 1.0.0-beta-62925-02' from 'packages.config'
Install failed. Rolling back...
Package 'Microsoft.Build.Tasks.Git 1.0.0-beta-62925-02' already exists in folder 'c:\scratch\ClassLibrary4\packages'
Added package 'Microsoft.Build.Tasks.Git 1.0.0-beta-62925-02' to 'packages.config'
Package 'Microsoft.SourceLink.Common 1.0.0-beta-62925-02' already exists in folder 'c:\scratch\ClassLibrary4\packages'
Added package 'Microsoft.SourceLink.Common 1.0.0-beta-62925-02' to 'packages.config'
Package 'Microsoft.SourceLink.GitHub 1.0.0-beta-62925-02' already exists in folder 'c:\scratch\ClassLibrary4\packages'
Added package 'Microsoft.SourceLink.GitHub 1.0.0-beta-62925-02' to 'packages.config'
Executing nuget actions took 883.56 ms
update-package : The result "" of evaluating the value "$(MicrosoftBuildTasksGitAssemblyFile)" of the "AssemblyFile" attribute in element <UsingTask> is not valid.
c:\scratch\ClassLibrary4\packages\Microsoft.Build.Tasks.Git.1.0.0-beta-62925-02\build\Microsoft.Build.Tasks.Git.targets
At line:1 char:1
+ update-package -reinstall
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Update-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.UpdatePackageCommand
Time Elapsed: 00:00:02.2867668
Manually removing packages from NuGet Package Manager UI, could remove the other two but Microsoft.Build.Tasks.Git refuses to go.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
reinstall or Uninstall-Package won't work for .NET ...
To repo: Visual Studio 2017, start a new .NET Framework Library project targeting .NET 4.5 or 4.0. Install Microsoft.SourceLink.Github from ...
Read more >Nuget re-targeting after upgrading from .Net Framework 4.5 ...
The packages will not be retargeted automatically, but there is an automated fix for ... Update-Package -Reinstall -ProjectName Project.
Read more >Reinstalling and Updating NuGet Packages
Details on when it's necessary to reinstall and update packages, as with broken package references in Visual Studio.
Read more >Migrate from packages.config to PackageReference
Details on how to migrate a project from the packages.config management ... Run NuGet restore - Right-click on the solution node in the ......
Read more >Manage NuGet packages with the Visual Studio ...
See how to work with NuGet packages by using PowerShell commands in the Visual Studio Package Manager Console.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The only way I was able to get rid of it was by manually deleting the files. I also had to go into the .csproj file for my project and delete any references to it. I then reinstalled it from the NuGet Package Manager UI, and it seems to be working now.
Filed https://github.com/NuGet/Home/issues/7347.