What is NuGetPackageImportStamp for?
What is NuGetPackageImportStamp for?
NuGetPackageImportStamp is a workaround for Visual Studio 2013 and later versions not being able to detect that a NuGet package added or removed an MSBuild import.
This workaround is not required for older versions of Visual Studio. Even in Visual Studio 2013, the property can safely be removed: if you close and re-open the solution, the imported MSBuild targets will be re-loaded by Visual Studio.
NuGet source code reveals that NuGet adds this property when a package adds or removes an MSBuild import. It uses a new GUID each time. Visual Studio 2013 detects that the project has changed and offers its reload. Just adding or removing an MSBuild import is not enough for Visual Studio 2013 to know the project has changed at runtime, which is what NuGet solves by this workaround.
The StyleCop.MSBuild NuGet package includes a custom MSBuild target so adding or removing this NuGet package will cause this property to be added.
UPDATE: Matt Ward's comment is correct and important.
There is still code in NuGet that adds the NuGet package stamp and the code no longer checks for Visual Studio 2013.
Here are my bottom line recommendations:
- Create your new projects with either Visual Studio or Powershell.
- When you update an old csproj, and it's not working, compare this old csproj to a new working csproj that you created with either Visual Studio or Powershell. If the new working csproj uses a
<NuGetPackageImportStamp>
directive, then add it into your old broken csproj and see if that fixes the issues; regardless of which Visual Studio version you're using. - If your old csproj still isn't working, consider the
<TargetFrameworkProfile>
directive. Does it exist in your new working csproj? Consider removing this.
MSB4011 is not suppressable by MSBuildWarningsAsMessages
remove the following section in .csproj file
<NuGetPackageImportStamp>209d4829</NuGetPackageImportStamp>
发现和这个有关
Microsoft.Bcl.Build.targets" cannot be imported again
如果下载了最新的nuget,那么需要移除NuGetPackageImportStamp。如果没有下载最新的nuget,就可以不用移除
作者:Chuck Lu GitHub |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
2020-05-26 Can I disable git pull?
2019-05-26 437. Path Sum III
2019-05-26 113. Path Sum II
2019-05-26 wsl中加载git之后,发现文件是修改状态
2019-05-26 wsl和windows相互访问文件夹
2019-05-26 Windows Subsystem for Linux
2017-05-26 wcf rest系列文章