Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Project file transformation
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl b"
xmlns:b="http://schemas.microsoft.com/developer/msbuild/2003">
<xsl:output method="xml" indent="yes" encoding="UTF-8"/>
<xsl:template match="/b:Project">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:apply-templates select="b:PropertyGroup"/>
<xsl:apply-templates select="b:ItemGroup"/>
<!-- Add the import for common C# build targets -->
<xsl:element name="Import" namespace="http://schemas.microsoft.com/developer/msbuild/2003">
<xsl:attribute name="Project">$(MSBuildToolsPath)\Microsoft.CSharp.targets</xsl:attribute>
</xsl:element>
</xsl:copy>
</xsl:template>
<xsl:template match="b:PropertyGroup[./b:ProjectGuid]">
<PropertyGroup xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<HgRootDirectory>$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), '.hgignore'))</HgRootDirectory>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<xsl:if test="b:AllowUnsafeBlocks">
<AllowUnsafeBlocks>
<xsl:value-of select="b:AllowUnsafeBlocks"/>
</AllowUnsafeBlocks>
</xsl:if>
<ProjectGuid>
<xsl:value-of select="b:ProjectGuid"/>
</ProjectGuid>
<OutputType>
<xsl:value-of select="b:OutputType"/>
</OutputType>
<AppDesignerFolder>
<xsl:value-of select="b:AppDesignerFolder"/>
</AppDesignerFolder>
<RootNamespace>
<xsl:value-of select="b:RootNamespace"/>
</RootNamespace>
<AssemblyName>
<xsl:value-of select="b:AssemblyName"/>
</AssemblyName>
<xsl:if test="b:ProjectTypeGuids">
<ProjectTypeGuids>
<xsl:value-of select="b:ProjectTypeGuids"/>
</ProjectTypeGuids>
</xsl:if>
<xsl:if test="b:AssemblyClsCompliant">
<AssemblyClsCompliant>
<xsl:value-of select="b:AssemblyClsCompliant"/>
</AssemblyClsCompliant>
</xsl:if>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NET_4</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE;NET_4</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Release\Microsoft.ApplicationServer.Http.XML</DocumentationFile>
</PropertyGroup>
</xsl:template>
<!--Assembly reference patterns-->
<!--GAC (assembly name) references-->
<xsl:template match="b:Reference[not(contains(@Include, '\'))]">
<Reference xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<xsl:attribute name="Include">
<xsl:value-of select="@Include"/>
</xsl:attribute>
<xsl:if test="b:HintPath">
<HintPath><xsl:value-of select="b:HintPath"/></HintPath>
</xsl:if>
</Reference>
</xsl:template>
<!--.NET 4.0 framework assemblies-->
<xsl:template match="b:Reference[contains(@Include,'\public\ext\sdk\CLR\netfx40rtm\')]">
<Reference xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<xsl:attribute name="Include">
<xsl:value-of select="substring-after(@Include, '\public\ext\sdk\CLR\netfx40rtm\')"/>
</xsl:attribute>
</Reference>
</xsl:template>
<!--Visual Studio 2010 SDK assemblies-->
<xsl:template match="b:Reference[contains(@Include,'$(INETROOT)\public\ext\VisualStudio\VS10RTM\PublicAssemblies\')]">
<Reference xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<xsl:attribute name="Include">
<xsl:value-of select="substring-after(@Include, '$(INETROOT)\public\ext\VisualStudio\VS10RTM\PublicAssemblies\')"/>
</xsl:attribute>
</Reference>
</xsl:template>
<!--ODataLib -->
<xsl:template match="b:Reference[contains(@Include, 'System.Data.OData.dll')]">
<Reference Include="$(HgRootDirectory)\Lib\Odata\System.Data.OData.dll" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"/>
</xsl:template>
<!--Unrecognized assembly reference-->
<xsl:template match="b:Reference">
<xsl:comment>Reference to an unrecognized assembly: <xsl:value-of select="./@Include"/></xsl:comment>
</xsl:template>
<!--Project reference patterns-->
<!--ODataLib project reference-->
<xsl:template match="b:ProjectReference[./b:Name='ODataLib']">
<xsl:comment>commenting out odatalib project reference</xsl:comment>
</xsl:template>
<!--Product code project references -->
<xsl:template match="b:ProjectReference[contains(@Include, '\source\') or contains(@Include, '$(WCFSource)')]">
<ProjectReference xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<xsl:attribute name="Include">$(HgRootDirectory)\WCFWebApi\Http\Src\<xsl:value-of select="b:Name"/>\<xsl:value-of select="b:Name"/>.csproj</xsl:attribute>
<Project>
<xsl:value-of select="b:Project"/>
</Project>
<Name>
<xsl:value-of select="b:Name"/>
</Name>
</ProjectReference>
</xsl:template>
<!--Testcommon project references -->
<xsl:template match="b:ProjectReference[contains(@Include, '\testcommon\')]">
<ProjectReference xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<xsl:attribute name="Include">$(HgRootDirectory)\WCFWebApi\Http\Test\testcommon\<xsl:value-of select="substring-after(@Include, '\testcommon\')" /></xsl:attribute>
<Project>
<xsl:value-of select="b:Project"/>
</Project>
<Name>
<xsl:value-of select="b:Name"/>
</Name>
</ProjectReference>
</xsl:template>
<!--Internal Moles project references - ignore -->
<xsl:template match="b:ProjectReference[contains(./b:Name, '.Moles')]">
<xsl:comment>Reference to internal Moles project: <xsl:value-of select="@Include"/></xsl:comment>
</xsl:template>
<!--Moles assembly includes-->
<xsl:template match="b:ItemGroup/b:Moles">
<xsl:comment>Temporarily removing ItemGroup/<xsl:value-of select="@Include"/> reference</xsl:comment>
</xsl:template>
<!--Identity xform-->
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment