Daniel Fisher (lennybacon.com)

SOA, DATA & THE WEB

Make a WebApplication project automatically publish on build

If you want to publish a Web Application project you can call MsBuild with parameters. Having a publish happen on each and every build - there is work to do.

Visual Studio project files are MsBuild files since Version 2005. There is a way to force MsBuild and Visual Studio behave as requested.

The project file needs to be edited slightly:

<PropertyGroup>
	<PublishDestination>..\..\..\out\YourPublishDirectory</PublishDestination>
</PropertyGroup>
<Target 
  Name="PublishToFileSystem" 
  DependsOnTargets="PipelinePreDeployCopyAllFilesToOneFolder" 
  AfterTargets="Build">
	<MakeDir 
	  Condition="!Exists($(PublishDestination))" 
	  Directories="$(PublishDestination)" 
	/>
	<ItemGroup>
	  <PublishFiles 
	    Include="$(_PackageTempDir)\**\*.*" 
	  />
	</ItemGroup>
	<Copy 
	  SourceFiles="@(PublishFiles)" 
	  DestinationFiles="@(PublishFiles->'$(PublishDestination)\%(RecursiveDir)%(Filename)%(Extension)')" 
	  SkipUnchangedFiles="True" 
	/>
</Target>

Comments

Write a comment