Automating creating NuGet package as part of build process

前端 未结 9 1813
伪装坚强ぢ
伪装坚强ぢ 2020-12-22 18:05

I have an automated build process that I\'d like to extend so I can build the libraries I am distributing via NuGet. Currently, running nuget.exe to create the packages is

相关标签:
9条回答
  • 2020-12-22 18:25

    I'm doing the thing you want to achieve already in my current project:

    Every assembly is built into its own proper nuget package, with dependencies in place.

    I solved it by making a package folder in the project for which I wanted to make a nuget package. There I configure a nuspec file with the necessary information about the nupkg

    There I make all the folders and unchanging files in there needed for Nuget package structure.

    I added a post build step in the project that copies the files that just have been built into the package folder and run nuget.exe

    So it goes:

    • Build Project.
    • Copy output back into Package\Lib of project.
    • Run nuget.exe with nuspec file in package folder.
    • Copy result to output folder next to the rest of the output.

    Nuget.exe has to be either in a fixed folder on your system and the buildserver (dirty solution) or included in your build (less dirty).

    Buildscript:

    Xcopy.exe /Y "$(TargetPath)" "$(ProjectDir)\Package\Lib" 
    cd "$(ProjectDir)Package" 
    "$(TargetDir)..\Buildscripts\Nuget.exe" pack MyPackage.nuspec xcopy /Y *.nupkg "$(TargetDir)" 
    

    In order to use this, the only thing you have to take care of, is deciding where to checkin the nuget.exe. I made a buildscripts folder on the top level of my development tree.

    0 讨论(0)
  • 2020-12-22 18:26

    Install the NuGet Powertools package in your sln and it will add a build target for creating the nupkg then just modify your CI to run that task as well. http://nuget.org/packages/NuGetPowerTools

    0 讨论(0)
  • 2020-12-22 18:39

    If you're in a TFS 2010 environment, the NuGetter project should solve the problem of creating nuget packages automatically. It creates one package for the entire build. It is in fact a TFS 2010 build workflow that does the job by calling nuget.exe with some arguments.

    0 讨论(0)
提交回复
热议问题