Reputation: 141
I have a MSBuild script that builds my windows forms application, generates the application manifest and signs it, then generates the deployment manifest. The script also generates the 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 the setup.exe file using a MSBuild script?
Thank you in advance for your help!
Upvotes: 5
Views: 5647
Reputation: 35136
The flags you want to msbuild are:
/target:publish
and:
/p:PublishDir=C:\Foo\
Notice that you must have a trailing \
on the publish dir or it simple perform the the dependent steps on publish (ie. build) and never actually generate an installer.
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 required.
Upvotes: 2
Reputation: 2526
You can use the built-in GenerateBootstrapper MSBuild task
When you do a Publish from Visual Studio, this is also what ClickOnce uses.
Check out C:\Windows\Microsoft.NET\Framework\\Microsoft.Common.Targets to see exactly what happens.
Look at the _DeploymentGenerateBootstrapper target.
Your CSharp project file contains some items and properties that this target uses to figure out:
Hopefully this makes sense. With a bit of work you can implement with your MSBuild file exactly what happens when you Publish from Visual Studio.
Upvotes: 3