Search code examples
visual-studiomsbuildwebdeployoctopus

Include web.release.config in Web Deploy output


By default when publishing a Web project using MSBuild/Visual Studio the config transforms are applied.

I would like to include the config transforms within the output.

Input

web.config  
web.Debug.config   
web.Release.config  

Default Output

web.config

Desired output

web.config  
web.Debug.config   
web.Release.config  

Solution

  • Include web.release.config in Web Deploy output

    By default, when publishing a website, VS does not package web.debug.config and web.release.config but only the web.config.

    To achieve what you want, you can add a custom target into publishprofile.pubxml to include these extra files.

    Please try this:

    <Target Name="CustomCollectFiles">
              <ItemGroup>
                <AdditionFiles Include="xxxxxxxxxxx\Web.Debug.config;xxxxxxxxx\Web.Release.config">
                </AdditionFiles>
                <FilesForPackagingFromProject Include="%(AdditionFiles.Identity)">
                   <DestinationRelativePath>%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
                </FilesForPackagingFromProject>
              </ItemGroup>
         </Target>
         <PropertyGroup>
              <CopyAllFilesToSingleFolderForPackageDependsOn>
                   CustomCollectFiles;
                   $(CopyAllFilesToSingleFolderForPackageDependsOn);
              </CopyAllFilesToSingleFolderForPackageDependsOn>
    
              <CopyAllFilesToSingleFolderForMsdeployDependsOn>
                   CustomCollectFiles;
                   $(CopyAllFilesToSingleFolderForMsdeployDependsOn);
              </CopyAllFilesToSingleFolderForMsdeployDependsOn>
         </PropertyGroup>
    

    And then you will find these files in the Publish folder when you finishing Publish step.

    Hope it could help you.