Don't overwrite root web.config on each build if already exists Should make F5-debug a lot easier
112 lines
4.4 KiB
XML
112 lines
4.4 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
|
|
<!--
|
|
****************************************************
|
|
VARIABLES
|
|
*****************************************************
|
|
-->
|
|
|
|
<PropertyGroup Condition="$(BuildingInsideVisualStudio) != true">
|
|
<SolutionRootFolder>$(MSBuildStartupDirectory)\..\src\</SolutionRootFolder>
|
|
<ConfigEnvironment></ConfigEnvironment>
|
|
</PropertyGroup>
|
|
|
|
<PropertyGroup Condition="$(BuildingInsideVisualStudio) == true">
|
|
<SolutionRootFolder>$(SolutionDir)</SolutionRootFolder>
|
|
<ConfigEnvironment>$(Computername).</ConfigEnvironment>
|
|
</PropertyGroup>
|
|
|
|
<PropertyGroup>
|
|
<ProjDir>$(ProjectDir)</ProjDir>
|
|
<ProjOutputDir>$(WebProjectOutputDir)</ProjOutputDir>
|
|
<WebConfigSource>$(ProjDir)web.Template.$(ConfigEnvironment)$(Configuration).config</WebConfigSource>
|
|
</PropertyGroup>
|
|
|
|
<PropertyGroup Condition="!Exists('$(WebConfigSource)')">
|
|
<WebConfigSource>$(ProjDir)web.Template.$(Configuration).config</WebConfigSource>
|
|
</PropertyGroup>
|
|
|
|
<PropertyGroup Condition="'$(ProjOutputDir)'==''">
|
|
<ProjOutputDir>$(ProjDir)</ProjOutputDir>
|
|
</PropertyGroup>
|
|
|
|
<PropertyGroup Condition="!HasTrailingSlash('$(ProjOutputDir)')">
|
|
<ProjOutputDir>$(ProjOutputDir)\</ProjOutputDir>
|
|
</PropertyGroup>
|
|
|
|
<ItemGroup>
|
|
<ConfigFiles Include="$(ProjDir)**\*.config" Exclude="$(ProjDir)web.config;$(ProjDir)web.*.config" />
|
|
<ConfigFiles Include="$(ProjDir)umbraco\config\create\UI.xml" />
|
|
</ItemGroup>
|
|
|
|
<!--
|
|
****************************************************
|
|
INCLUDES
|
|
*****************************************************
|
|
-->
|
|
|
|
<UsingTask
|
|
TaskName="TransformXml"
|
|
AssemblyFile="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.Tasks.dll"
|
|
/>
|
|
|
|
<!--
|
|
****************************************************
|
|
TARGETS
|
|
*****************************************************
|
|
-->
|
|
|
|
<!-- Make sure web.config will be there even for package/publish -->
|
|
<Target Name="CopyWebConfig" BeforeTargets="Build;Rebuild">
|
|
|
|
<PropertyGroup>
|
|
<OriginalFileName>$(ProjDir)Web.Template.config</OriginalFileName>
|
|
<OutputFileName>$(ProjOutputDir)Web.config</OutputFileName>
|
|
</PropertyGroup>
|
|
|
|
<Copy
|
|
SourceFiles="$(OriginalFileName)"
|
|
DestinationFiles="$(OutputFileName)"
|
|
OverwriteReadOnlyFiles="true"
|
|
SkipUnchangedFiles="false"
|
|
Condition="!Exists('$(OutputFileName)')"
|
|
/>
|
|
</Target>
|
|
|
|
<Target Name="CustomTarget" AfterTargets="CopyWebConfig">
|
|
<Message Text="Building in VS? $(BuildingInsideVisualStudio)" Importance="high" />
|
|
<Message Text="Transforming: $(WebConfigSource), running MSBuild on project $(MSBuildProjectDirectory)" Importance="high" />
|
|
|
|
<PropertyGroup>
|
|
<OriginalFileName>$(ProjDir)Web.Template.config</OriginalFileName>
|
|
<OutputFileName>$(ProjOutputDir)Web.config</OutputFileName>
|
|
</PropertyGroup>
|
|
|
|
<Message Text="$(OriginalFileName)" Importance="high" />
|
|
<Message Text="$(OutputFileName)" Importance="high" />
|
|
|
|
<TransformXml Condition="$(BuildingInsideVisualStudio) == ''" Source="$(OriginalFileName)" Transform="$(WebConfigSource)" Destination="$(OutputFileName)" />
|
|
<TransformXml Condition="$(BuildingInsideVisualStudio) == 'true'" Source="$(OutputFileName)" Transform="$(WebConfigSource)" Destination="$(OutputFileName)" />
|
|
</Target>
|
|
|
|
<Target Name="ResetConfigFiles" Condition="$(ProjDir) != $(ProjOutputDir)" BeforeTargets="Build;Rebuild" Inputs="@(ConfigFiles)" Outputs="%(Identity).Dummy">
|
|
|
|
<PropertyGroup>
|
|
<OriginalFileName>@(ConfigFiles)</OriginalFileName>
|
|
<ModifiedFileName>$(OriginalFileName.Replace("%(ConfigFiles.Extension)",".$(Configuration)%(ConfigFiles.Extension)"))</ModifiedFileName>
|
|
<OutputFileName>$(OriginalFileName.Replace("$(ProjDir)", "$(ProjOutputDir)"))</OutputFileName>
|
|
</PropertyGroup>
|
|
|
|
<Message Text="$(OriginalFileName)" Importance="high" />
|
|
<Message Text="$(OutputFileName)" Importance="high" />
|
|
|
|
<Copy SourceFiles="$(ModifiedFileName)"
|
|
DestinationFiles="$(OutputFileName)"
|
|
OverwriteReadOnlyFiles="true"
|
|
SkipUnchangedFiles="false"
|
|
Condition="Exists('$(ModifiedFileName)')"/>
|
|
|
|
</Target>
|
|
|
|
</Project> |