figursagsmats
figursagsmats

Reputation: 175

Pack nuspec file during build in Visual Studio

I have a VS2017 solution with multiple projects that generates a cross-platform nuget-package. The package is generated by running nuget pack on my specific nuspec file. I would like to automatically performs this action during Visual Studio build instead of doing it manually each time. Is this possible?

Upvotes: 1

Views: 948

Answers (1)

Leo Liu
Leo Liu

Reputation: 76710

Pack nuspec file during build in Visual Studio. Is this possible?

The answer is yes. You can simple add a pro-build or post-build event (Project->properties->Build Events) to generate nuget package with below command line:

nuget.exe pack "$(ThePathOfYour .nuspec)\TestPackNupsec.csproj.nuspec"

Note: You should add the nuget.exe as a system variable, so that you can use it anywhere without specifying the specific path of nuget, or you need specify the full path of nuget in that command line, like:

C:\Users\<UserName>\nuget.exe

With this command line in the build-event, we could generate Pack nuspec file during build in Visual Studio:

enter image description here

Upvotes: 1

Related Questions