TTCG
TTCG

Reputation: 9113

Azure DevOps Build Pipeline: Create NuGet Package from MsBuild.exe Solution

I'm trying to build the Asp.Net framework 461 Web Application and pack the dlls in NuGet package which is going to be used for deployment in Octopus.

Please note that, I am using:

enter image description here

It built the solution and it packaged the artifact in deploy package format with xxx.deploy batch file. However, when I tried to deploy onto the server, it's forcing me to install "Web Deploy (msdeploy.exe)" on the server which I don't want to do.

The content of the NuGet package is like the following: The contents of the build are embedded in the zip file and extra deployment files.

enter image description here

Our ex-DevOps managed these builds previously and when I compared his NuGet packages with mine, they are completely different. In his version, all aspx, ascx and bin folder is located on the top level of the NuGet package.

enter image description here

I would like to pack my NuGet package without these additional deploy files.

The current build parameter in my AzureDevOps is

/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\\"

I tried to change it to /p:WebPublishMethod=FileSystem /p:PackageAsSingleFile=false but I still couldn't achieve the NuGet package format as I wanted.

It generates the built output onto -> $myproject\obj\Release\Package\PackageTmp location.

I would like to know whether there is a way to generate the NuGet package without that extra zip file? Or do I need to write manual powershell script and execute Octo.exe to pack the contents under that ...\PackageTmp directory?

Is there anyway Create Nuget Package task to define that I want to pack only ..\PackageTmp directory?

Upvotes: 0

Views: 1809

Answers (1)

Leo Liu
Leo Liu

Reputation: 76928

Azure DevOps Build Pipeline: Create NuGet Package from MsBuild.exe Solution

Indeed, if you want to pack only pack the files in the folder ..\PackageTmp, we have to filter the files for the source file of the Create Octopus Package task when you use the /p:WebPublishMethod=Package, since there is no filter option for the Create Octopus Package task.

You could use the copy task with the Contents **\PackageTmp\** to filter the files in the PackageTmp folder:

enter image description here

What is more, if the publish method is not what you care about, using /p:WebPublishMethod=FileSystem /p:PackageAsSingleFile=false should be more easy to resolve this issue.

When I use following arguments to publish the Web Application:

/p:SkipInvalidConfigurations=true /p:DeployOnBuild=true /p:WebPublishMethod=FileSystem /p:publishUrl="$(build.artifactstagingdirectory)\\" /p:DeployDefaultTarget=WebPublish

Then use the Package Application for Octopus to pack it:

enter image description here

Finally, I could get the package with all files as same in the PackageTmp folder:

enter image description here

Hope this helps.

Upvotes: 0

Related Questions