Permalink
Browse files

Apply transform files from modules into publish package

  • Loading branch information...
Bartłomiej Mucha
Bartłomiej Mucha committed Oct 24, 2018
2 parents 9f26f20 + 4dbb8cc commit a07d022937de29b15fcfe74f7d08ca4e393ce629
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
@@ -109,7 +109,10 @@
<Content Include="App_Config\Include\Feature\Feature.Accounts.config">
<SubType>Designer</SubType>
</Content>
<None Include="App_Config\Security\Domains.config.xdt" />
<None Include="App_Config\Security\Domains.config.xdt">
<ApplyTransformOnPublish>True</ApplyTransformOnPublish>
<SubType>Designer</SubType>
</None>
<None Include="Properties\PublishProfiles\Standalone.pubxml" />
<Content Include="Scripts\Accounts\Accounts.js" />
<Content Include="Views\Accounts\Login.cshtml" />
@@ -115,7 +115,9 @@
</ItemGroup>
<ItemGroup>
<Content Include="App_Config\Include\Foundation\Foundation.Accounts.config" />
<None Include="App_Config\Security\domains.config.xdt" />
<None Include="App_Config\Security\Domains.config.xdt">
<ApplyTransformOnPublish>true</ApplyTransformOnPublish>
</None>
<None Include="Properties\PublishProfiles\Standalone.pubxml" />
<None Include="Web.Debug.config">
<DependentUpon>Web.config</DependentUpon>
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
@@ -131,9 +131,14 @@
<SubType>Designer</SubType>
</Content>
<Content Include="App_Config\Include\Foundation\Foundation.SitecoreExtensions.Serialization.config" />
<None Include="App_Config\layers.config.xdt" />
<None Include="App_Config\Layers.config.xdt">
<ApplyTransformOnPublish>true</ApplyTransformOnPublish>
</None>
<None Include="web.config" />
<None Include="Properties\PublishProfiles\Standalone.pubxml" />
<None Include="Web.config.xdt">
<ApplyTransformOnPublish>true</ApplyTransformOnPublish>
</None>
<None Include="web.Debug.config">
<DependentUpon>web.config</DependentUpon>
</None>
@@ -110,7 +110,9 @@
<SubType>Designer</SubType>
</Content>
<Content Include="favicon.ico" />
<None Include="App_Config\layers.config.xdt" />
<None Include="App_Config\Layers.config.xdt">
<ApplyTransformOnPublish>true</ApplyTransformOnPublish>
</None>
<None Include="App_Data\packages\Habitat.xml" />
<None Include="Properties\PublishProfiles\Standalone.pubxml" />
<Content Include="App_Config\Environment\Project\Habitat.Dev.config">
@@ -0,0 +1,21 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<!--Default values -->
<ItemDefinitionGroup>
<None>
<ApplyTransformOnPublish>false</ApplyTransformOnPublish>
</None>
</ItemDefinitionGroup>

<Target
Name="GetTransformFilesToApplyOnPublish"
DependsOnTargets="PrepareForBuild;AssignTargetPaths"
Returns="@(_TransformFilesToApplyOnPublish)">

<ItemGroup>
<_TransformFilesToApplyOnPublish Include="@(_NoneWithTargetPath->'%(FullPath)')" Condition="'%(ApplyTransformOnPublish)' == 'true'"/>
</ItemGroup>

</Target>

</Project>
@@ -1,5 +1,7 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<!-- Content Files-->

<PropertyGroup>
<PipelineCollectFilesPhaseDependsOn>
$(PipelineCollectFilesPhaseDependsOn);
@@ -9,15 +11,66 @@

<Target Name="CollectContentFilesFromHelixModules">
<MSBuild Projects="@(ProjectReference)" Targets="ContentFilesProjectOutputGroup" BuildInParallel="$(BuildInParallel)">
<Output TaskParameter="TargetOutputs" ItemName="_ContentFilesFromHelixModules" />
<Output TaskParameter="TargetOutputs" ItemName="ContentFilesFromHelixModules" />
</MSBuild>
<ItemGroup>
<ContentFilesFromHelixModules Include="@(_ContentFilesFromHelixModules)">
<ContentFilesFromHelixModules>
<DestinationRelativePath>%(TargetPath)</DestinationRelativePath>
</ContentFilesFromHelixModules>

<FilesForPackagingFromProject Include="@(ContentFilesFromHelixModules)" />
<FilesForPackagingFromProject Include="@(ContentFilesFromHelixModules)" />
</ItemGroup>
</Target>

<!-- Transform Files (extending Slow Cheetah)-->

<PropertyGroup>
<PipelineCollectFilesPhaseDependsOn>
$(PipelineCollectFilesPhaseDependsOn);
CollectTransformFilesToApplyOnPublish;
</PipelineCollectFilesPhaseDependsOn>
</PropertyGroup>

<Target Name="CollectTransformFilesToApplyOnPublish">
<MSBuild Projects="@(ProjectReference)" Targets="GetTransformFilesToApplyOnPublish" BuildInParallel="$(BuildInParallel)" Properties="CustomBeforeMicrosoftCSharpTargets=$(MSBuildThisFileDirectory)Helix.Module.targets">
<Output TaskParameter="TargetOutputs" ItemName="TransformFilesToApplyOnPublish" />
</MSBuild>

<ItemGroup>
<TransformFilesToApplyOnPublish>
<TransformFile>%(FullPath)</TransformFile>
<TargetPathToFileToTransform>$([System.IO.Path]::Combine($([System.IO.Path]::GetDirectoryName(%(TargetPath))),%(Filename)))</TargetPathToFileToTransform>
</TransformFilesToApplyOnPublish>

<TransformFilesToApplyOnPublish>
<DestinationFileInPackageDir>$(_PackageTempDir)\%(TargetPathToFileToTransform)</DestinationFileInPackageDir>
<DestinationFileInPublishDir>$(PublishUrl)\%(TargetPathToFileToTransform)</DestinationFileInPublishDir>
</TransformFilesToApplyOnPublish>
</ItemGroup>

<Message Text="Transform file to apply on publish: %(TransformFilesToApplyOnPublish.TransformFile) %(DestinationFileInPackageDir) %(DestinationFileInPublishDir)" Importance="normal" Condition="@(TransformFilesToApplyOnPublish) != ''"/>

<ItemGroup>
<FilesToCopyFromPublishDirToPackageDir Include="@(TransformFilesToApplyOnPublish -> '%(DestinationFileInPublishDir)')" Condition="Exists('%(DestinationFileInPublishDir)')">
<DestinationRelativePath>%(TargetPathToFileToTransform)</DestinationRelativePath>
</FilesToCopyFromPublishDirToPackageDir>
<FilesToCopyFromPublishDirToPackageDir Remove="@(FilesToCopyFromPublishDirToPackageDir)" Condition="@(FilesToCopyFromPublishDirToPackageDir) != '' and @(FilesForPackagingFromProject) != '' and %(DestinationRelativePath) != ''"/>

<FilesForPackagingFromProject Include="@(FilesToCopyFromPublishDirToPackageDir)" Condition=""/>
</ItemGroup>

<Message Text="File copied to package dir: %(FilesToCopyFromPublishDirToPackageDir.Identity)" Importance="normal" Condition="@(FilesToCopyFromPublishDirToPackageDir) != ''"/>
</Target>

<Target Name="ApplyTransformsOnPublish" AfterTargets="ScApplyWebTransforms" DependsOnTargets="CollectTransformFilesToApplyOnPublish">

<SlowCheetah.TransformTask Source="%(TransformFilesToApplyOnPublish.DestinationFileInPackageDir)"
Transform="%(TransformFile)"
Destination="%(DestinationFileInPackageDir)"
Condition="Exists('%(TransformFile)') and Exists('%(DestinationFileInPackageDir)')" />

<Message Text="Transformed %(TransformFilesToApplyOnPublish.DestinationFileInPackageDir) using %(TransformFile) into %(DestinationFileInPackageDir)" Importance="high" Condition="Exists('%(TransformFile)') and Exists('%(DestinationFileInPackageDir)')"/>

</Target>

</Project>
@@ -1,4 +1,4 @@
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -196,11 +196,20 @@
<Project>{c98ead78-4d83-4789-a621-6011c3d7314d}</Project>
<Name>Sitecore.Common.Website</Name>
</ProjectReference>
<ProjectReference Include="..\Project\Habitat\code\Sitecore.Habitat.Website.csproj">
<Project>{86cadb26-5817-46b6-88c7-76d5753722c3}</Project>
<Name>Sitecore.Habitat.Website</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform">
<Version>2.0.0</Version>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.SlowCheetah">
<Version>3.1.66</Version>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>

0 comments on commit a07d022

Please sign in to comment.