Skip to content

Instantly share code, notes, and snippets.

@cary205
Forked from beccasaurus/README.markdown
Created September 15, 2024 04:06
Show Gist options
  • Select an option

  • Save cary205/75ee51e6e434eda8a35af443d9cfcd92 to your computer and use it in GitHub Desktop.

Select an option

Save cary205/75ee51e6e434eda8a35af443d9cfcd92 to your computer and use it in GitHub Desktop.
MSBuild equivalent of Visual Studio "Publish"

Publish via MSBuild

Note: the publish-via-msbuild.bat shown here simply builds the site and drops it into a directory, transforming the Web.configs

It does NOT sync the directory in any meaningful way.

To do that, I recommend using a tool like Rsync or MSDeploy

MSDeploy example:

msdeploy.exe -verb:sync -source:dirPath="C:\mysite" -dest:dirPath="C:\this\is\where\i\want\to\deploy"  -enableRule:DoNotDeleteRule

The DoNotDeleteRule says "hey, if this file exists in the destination but not in the source, leave it alone"

msbuild /t:Rebuild /p:Configuration=Release;OutDir=C:\mysite\bin\;WebProjectOutputDir=C:\mysite\;UseWPP_CopyWebApplication=True;PipelineDependsOnBuild=False src\MySite.csproj
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment