Create setup.exe to deploy ClickOnce from the command line using MSBuild

I have an MSBuild script that creates my application for Windows forms, generates an application manifest and signs it, and then generates a deployment manifest. The script also creates a publish.htm file for me.

Now I need to generate the setup.exe file, and so far I have not been able to figure out how VS generates it. How can I generate setup.exe file using MSBuild script?

Thank you in advance for your help!

+4
source share
2 answers

You can use the built-in GenerateBootstrapper MSBuild Task

When you publish from Visual Studio, it also uses ClickOnce.

Check C: \ Windows \ Microsoft.NET \ Framework \\ Microsoft.Common.Targets to see what exactly is happening.

Look at the _DeploymentGenerateBootstrapper target.

The CSharp project file contains some elements and properties that this goal uses to determine:

  • If it is going to create a bootstrapper (property BootstrapperEnabled)
  • Packages for creating a boot file for a group of items (BootstrapperPackage)
  • If packages will be installed from (BootstrapperComponentsLocation property)

Hope this makes sense. With a little work, you can implement with your MSBuild file what happens when you publish from Visual Studio.

+2
source

Flags you want to create msbuild:

/target:publish 

and

 /p:PublishDir=C:\Foo\ 

Note that you must have trailing \ in the publish directory or just follow the dependent steps for publishing (i.e. build) and never create a script.

You may be interested in the msbuild npm package:

 var msbuild = require('msbuild'); var path = require('path'); // Config var source = 'source/Bar/Bar.App/Bar.App.csproj'; var deploy = path.join(__dirname, 'deploy'); // Build the project var builder = new msbuild(); builder.sourcePath = source; builder.overrideParams.push('/p:PublishDir=' + deploy + "\\"); // <-- Installer builder.overrideParams.push('/Target:rebuild;publish'); builder.overrideParams.push('/P:Configuration=Release'); builder.overrideParams.push('/P:verbosity=diag'); builder.overrideParams.push('/P:Platform=x86'); builder.overrideParams.push('/fl'); builder.overrideParams.push('/flp:logfile=build.log;verbosity=diagnostic'); builder.publish(); 

... which you would run something like:

 npm install msbuild node builder.js 

No powershell is required.

+1
source

All Articles