Skip to content

Instantly share code, notes, and snippets.

@flakey-bit
Last active June 4, 2018 00:42
Show Gist options
  • Save flakey-bit/65e34f1bd9dbca275e5f47d8866c3534 to your computer and use it in GitHub Desktop.
Save flakey-bit/65e34f1bd9dbca275e5f47d8866c3534 to your computer and use it in GitHub Desktop.
Create WebDeploy package which includes transform file (Web.Release.config) - don't apply transform. Also keeps the transform file as dependent so that the "preview-transform" functionality in Visual Studio works.
/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\\"
...
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <CopyAllFilesToSingleFolderForMsdeployDependsOn>
+ CustomCollectFiles;
+ $(CopyAllFilesToSingleFolderForMsdeployDependsOn);
+ </CopyAllFilesToSingleFolderForMsdeployDependsOn>
+ <TransformWebConfigEnabled>False</TransformWebConfigEnabled>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>
</ProductVersion>
...
- <None Include="Web.Release.config">
+ <Content Include="Web.Release.config">
<IsTransformFile>True</IsTransformFile>
<DependentUpon>Web.config</DependentUpon>
- </None>
+ </Content>
</ItemGroup>
...
+ <Target Name="CustomCollectFiles">
+ <ItemGroup>
+ <_CustomFiles Include="Web.Release.config" />
+ <FilesForPackagingFromProject Include="%(_CustomFiles.Identity)">
+ <DestinationRelativePath>Web.Release.config</DestinationRelativePath>
+ </FilesForPackagingFromProject>
+ </ItemGroup>
+ </Target>
</Project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment