24 May 2016

visual studio web deployment / deploying extra files

Deploying extra files with Web Deploy 

http://www.asp.net/mvc/overview/deployment/visual-studio-web-deployment/deploying-extra-files

The official search result shows a somewhat complex approach to including files to the project deployment, a more simpler approach is to fake that the files have been included as content. This approach requires the files to be accessible at the root prior to deploying.

By creating a *.wpp.targets (named the same as your project) you can add to the project files source prior to building. If you had included your content from Visual Studio to the project, it would have resulted in the external content being saved as <ItemGroup> and Content Include xxx for each file. By doing this manually you can use search patterns to add unknown amounts of files using \**\*.
ProjectName.wpp.targets
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
 <ItemGroup>
  <Content Include="css\**\*" />
  <Content Include="content\**\*" />
 </ItemGroup>
</Project>

It is that simple to include external content.

Another classic issue using webdeployment is to control the content of your web.config, AutoParameterizationWebConfigConnectionStrings is the solution for this. http://blog.jan.hebnes.dk/2015/07/umbraco-to-azure-msdeploy-error.html

No comments: