What is NuGetPackageImportStamp for?

When adding certain NuGet packges to a project, sometimes a strange item appears in the first property group of the .csproj file.

<PropertyGroup>
  ...
  <NuGetPackageImportStamp>3d051ef3</NuGetPackageImportStamp>
</PropertyGroup>

The stamp is different every time, and doesn't appear to be sequential.

I can't find any reference to <NuGetPackageImportStamp> in the NuGet documentation. What is it for and how does it work? Is it necessary?

One package that appears to add this every time is StyleCop.MSBuild, at least with the current 4.7.49 version. Simply add that package to a new project and you'll see this mystery item appear in your project file.

Answers


It is a workaround for Visual Studio 2013.

If you look at the NuGet source code you will see that NuGet adds this property when a NuGet package adds or removes an MSBuild import. It uses a new guid each time and seems to be a way to tell Visual Studio 2013 that the project has changed. I assume this is because that just adding or removing an MSBuild import is not enough for Visual Studio to know the project has changed at runtime.

The StyleCop.MSBuild NuGet package includes a custom MSBuild target so adding or removing this NuGet package will cause this property to be added.

I believe the property is not required so you should be OK to remove it. If you close and re-open the solution then the imported MSBuild targets will be re-loaded by Visual Studio.

This workaround is not required for other versions of Visual Studio.


Need Your Help

Excel editing from 'Protected View' causes 'run-time error 5'

excel vba excel-vba

I have a macro-enabled spreadsheet (Excel 2010) that works fine, unless you're sending it to somebody through the internet. If sending it, the recipient has to 'enable editing' in Protected View an...

How to enable/disable select tag and post it (even if disabled) with knockout

post knockout.js html-select disabled-input

I have a complex form with many selects whose state (enabled/disabled) depends on the value of some other controls, so it could happen that these selects are disabled when submitting the form (and ...

How to get an icecast header with dart

dart httprequest icecast

im trying to get icecast metadata with dart on the server side of things.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.