Visual studio 2015 project missing all references

前端 未结 9 724
星月不相逢
星月不相逢 2021-01-30 06:45

Starting from today, a WPF project that belongs to a solution with 20 projects, set all my references to missing

I\'ve just checked the MS suggestion and the othe

相关标签:
9条回答
  • 2021-01-30 06:57

    The resolution to this issue is.

    Whenever you import a project to VS 2015 it modifies your .csproj. So, in order to fix it. Right click on .csproj and open it in notepad or any editor and delete the following

    <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
      <PropertyGroup>
        <ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
      </PropertyGroup>
      <Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
    </Target>
    

    Then build your solution and it should work.

    0 讨论(0)
  • 2021-01-30 07:04

    It can help to force rebuild the nuget packages. Go to the nuget console and use the following commands: (TOOLS > Options > Package Manager > Package Manager Conbsole)

    Update-Package -reinstall -ProjectName "MyProject" -safe
    

    The safe parameter will actually not update the packages, but only reinstall them. If that didn't help, you can try to actually update them (but make sure you have a copy of the project somewhere, just in case.)

    Update-Package -reinstall -ProjectName "MyProject"
    

    To force update just one package, use:

    Update-Package -id Microsoft.Package.Name -ProjectName "MyProject"
    
    0 讨论(0)
  • 2021-01-30 07:10

    This error may occur if you miss .targets file in nuget packages folder. In my case it was packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets

    Usually it happens when I'm adding packages to git repository (common .gitignore file is ignoring build folder everywhere) and checkout on another computer.

    Tip: you can modify .gitignore file to include all files in packages folder. Append these lines to the bottom:

    # Include all files in NuGet packages directory
    !/packages/**/
    
    0 讨论(0)
提交回复
热议问题