PTVS/Build/Common.Build.CSharp.targets

168 строки
9.2 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- This property may have been set by the project. -->
<PropertyGroup Condition="$(SuppressCommonAssemblyVersion)">
<DefineConstants>$(DefineConstants);SUPPRESS_COMMON_ASSEMBLY_VERSION</DefineConstants>
</PropertyGroup>
<!-- If any references packages have been installed, use them. -->
<PropertyGroup>
<ResolveAssemblyReferencesDependsOn>$(ResolveAssemblyReferencesDependsOn);_AddPTVSReferences</ResolveAssemblyReferencesDependsOn>
</PropertyGroup>
<Target Name="_AddPTVSReferences">
<ItemGroup>
<_NugetAssemblies Include="$(PackagesPath)\Microsoft.VisualStudio.*\lib\Microsoft.VisualStudio.*.dll" />
<_NugetAssemblies Include="$(PackagesPath)\Microsoft.VisualStudio.*\lib\net20\Microsoft.VisualStudio.*.dll" />
<_NugetAssemblies Include="$(PackagesPath)\Microsoft.VisualStudio.*\lib\net35\Microsoft.VisualStudio.*.dll" />
<_NugetAssemblies Include="$(PackagesPath)\Microsoft.VisualStudio.*\lib\net40\Microsoft.VisualStudio.*.dll" />
<_NugetAssemblies Include="$(PackagesPath)\Microsoft.VisualStudio.*\ref\net45\Microsoft.VisualStudio.*.dll" />
<_NugetAssemblies Include="$(PackagesPath)\Microsoft.VisualStudio.*\lib\net45\Microsoft.VisualStudio.*.dll" />
<_NugetAssemblies Include="$(PackagesPath)\Microsoft.VisualStudio.*\lib\net46\Microsoft.VisualStudio.*.dll" />
<_NugetAssemblies Include="$(PackagesPath)\Microsoft.VisualStudio.*\lib\net461\Microsoft.VisualStudio.*.dll" />
<_NugetAssemblies Include="$(PackagesPath)\Microsoft.VisualStudio.*\lib\net472\Microsoft.VisualStudio.*.dll" />
<_NugetAssemblies Include="$(PackagesPath)\Microsoft.VisualStudio.*\lib\netstandard1.0\Microsoft.VisualStudio.*.dll" />
<_NugetAssemblies Include="$(PackagesPath)\Microsoft.VisualStudio.*\lib\netstandard2.0\Microsoft.VisualStudio.*.dll" />
<_NugetAssemblies Include="$(PackagesPath)\Microsoft.VisualStudio.*\lib\vs16\Microsoft.*.dll" />
<_NugetAssemblies Include="$(PackagesPath)\Microsoft.Build*\lib\net472\Microsoft.*.dll" />
<_NugetAssemblies Include="$(PackagesPath)\Microsoft.Internal.VisualStudio.*\lib\net45\Microsoft.Internal.VisualStudio.*.dll" />
<_NugetAssemblies Include="$(PackagesPath)\Microsoft.Internal.VisualStudio.*\lib\net472\Microsoft.Internal.VisualStudio.*.dll" />
<_NugetAssemblies Include="$(PackagesPath)\Microsoft.Python.*\lib\netstandard2.0\Microsoft.Python.*.dll" />
<_NugetAssemblies Include="$(PackagesPath)\Microsoft.Extensions.*\lib\netstandard2.0\Microsoft.Extensions.*.dll" />
<_NugetAssemblies Include="$(PackagesPath)\StreamJsonRpc*\lib\netstandard2.0\StreamJsonRpc.dll" />
<_NugetAssemblies Include="$(PackagesPath)\System.*\lib\netstandard2.0\System.*.dll" />
<_NugetAssemblies Include="$(PackagesPath)\Microsoft.NET.*\lib\net472\Microsoft.NET.*.dll" />
<_NugetAssemblies Include="$(PackagesPath)\Microsoft.ServiceHub.*\lib\netstandard2.0\Microsoft.ServiceHub.*.dll" />
</ItemGroup>
<PropertyGroup>
<AssemblySearchPaths>
$(BuildRoot)Python\References\Dev$(VSTarget);
$(BuildRoot)Python\References\Common;
@(_NugetAssemblies->'%(RootDir)%(Directory)',';');
$(AssemblySearchPaths);
</AssemblySearchPaths>
</PropertyGroup>
</Target>
<!--
Returns the paths and names required for generating a vsixmanifest file.
The default targets for this occasionally return the wrong files depending
on some internal ordering.
-->
<Target Name="_GetTargetPath" Returns="@(_ResolvedReference1)">
<ItemGroup>
<_ResolvedReference1 Include="$(TargetPath)" />
</ItemGroup>
</Target>
<Target Name="_GetAssemblyName" Returns="@(_ResolvedReference2)">
<ItemGroup>
<_ResolvedReference2 Include="$(TargetPath)">
<UseAssemblyName>true</UseAssemblyName>
</_ResolvedReference2>
</ItemGroup>
</Target>
<!--
Transforms our ConditionalEmbeddedResource into EmbeddedResource item
groups with textual replacements in the .resx file.
Currently the search and replace just updates the VS target version and
the build root.
-->
<Target Name="ConditionalResx"
BeforeTargets="MainResourcesGeneration"
Inputs="@(ConditionalEmbeddedResource)"
Outputs="@(ConditionalEmbeddedResource->'$(IntermediateOutputPath)%(Filename).xform.resx')">
<WriteLinesToFile
File="@(ConditionalEmbeddedResource->'$(IntermediateOutputPath)%(Filename).xform.resx')"
Lines="$([System.IO.File]::ReadAllText(`%(FullPath)`).Replace(`_VSVERSION_`,`$(VSTarget)`).Replace(`_BUILDROOT_`, `$(BuildRoot)`))"
Overwrite="true"/>
<Message Text="Written to @(ConditionalEmbeddedResource->'$(IntermediateOutputPath)%(Filename).xform.resx')" Importance="normal" />
<ItemGroup>
<FileWrites Include="@(ConditionalEmbeddedResource->'$(IntermediateOutputPath)%(Filename).xform.resx')" />
<EmbeddedResource Include="@(ConditionalEmbeddedResource->'$(IntermediateOutputPath)%(Filename).xform.resx')">
<ManifestResourceName>%(ConditionalEmbeddedResource.ManifestResourceName)</ManifestResourceName>
<MergeWithCTO Condition="'%(ConditionalEmbeddedResource.MergeWithCTO)' != ''">%(ConditionalEmbeddedResource.MergeWithCTO)</MergeWithCTO>
<LastGenOutput Condition="'%(ConditionalEmbeddedResource.LastGenOutput)' != ''">%(ConditionalEmbeddedResource.LastGenOutput)</LastGenOutput>
<Generator Condition="'%(ConditionalEmbeddedResource.Generator)' != ''">%(ConditionalEmbeddedResource.Generator)</Generator>
</EmbeddedResource>
</ItemGroup>
</Target>
<!--
Processes {Lambda} converters in WPF XAML files and generates code for them.
-->
<PropertyGroup>
<BuildTasksProjectDir>$(BuildRoot)\Common\Tools\BuildTasks\</BuildTasksProjectDir>
<!-- Deliberately omit trailing backslashes so we can quote these on the
command line. -->
<BuildTasksIntDir>$(IntermediateOutputRoot)BuildTasks</BuildTasksIntDir>
<BuildTasksOutDir>$(ToolsOutputPath)BuildTasks</BuildTasksOutDir>
<BuildTasksAssembly>$(BuildTasksOutDir)\Microsoft.VisualStudioTools.BuildTasks.dll</BuildTasksAssembly>
</PropertyGroup>
<ItemGroup>
<BuildTasksSourceFiles Include="$(BuildTasksProjectDir)*.csproj"/>
<BuildTasksSourceFiles Include="$(BuildTasksProjectDir)**\*.cs"/>
</ItemGroup>
<!-- Use Exec rather than MSBuild here to completely isolate the task build - otherwise it interferes with the main build.
To avoid spawning a new msbuild.exe process again and again unnecessarily, do a quick up-to-date check (effectively
duplicating the one done by .csproj) on the target. -->
<Target Name="_BuildBuildTasks"
BeforeTargets="ExtractLambdasFromXaml"
Condition="$(MSBuildProjectDir) != $(BuildTasksProjectDir)"
Inputs="@(BuildTasksSourceFiles)"
Outputs="$(BuildTasksAssembly)">
<Exec Command='"$(MSBuildBinPath)\msbuild.exe" "$(BuildTasksProjectDir)BuildTasks.csproj" /p:Configuration=$(Configuration) /p:VSTarget=$(VSTarget) /p:BuildRoot="$(BuildRoot.TrimEnd(`\`))\\" /p:OutputPath="$(BuildTasksOutDir)" /p:IntermediateOutputPath="$(BuildTasksIntDir)"'/>
<Touch Files='$(BuildTasksAssembly)'/>
</Target>
<UsingTask AssemblyFile="$(BuildTasksAssembly)" TaskName="Microsoft.VisualStudioTools.BuildTasks.ExtractLambdasFromXaml"/>
<Target Name="ExtractLambdasFromXaml"
Inputs="@(Page)"
Outputs="@(Page->'$(IntermediateOutputPath)%(Filename).g.lambdas$(DefaultLanguageSourceExtension)')">
<ExtractLambdasFromXaml InputFileName="@(Page->'%(FullPath)')" OutputFileName="$(IntermediateOutputPath)%(Filename).g.lambdas$(DefaultLanguageSourceExtension)" Language="$(Language)">
<Output TaskParameter="OutputFileName" ItemName="Compile"/>
<Output TaskParameter="OutputFileName" ItemName="FileWrites"/>
</ExtractLambdasFromXaml>
</Target>
<Target Name="_CompileImageManifest" Condition="@(ImageManifest) != ''">
<Copy SourceFiles="%(ImageManifest.FullPath)" DestinationFiles="$(IntermediateOutputPath)%(Filename)%(Extension)" OverwriteReadOnlyFiles="true" />
<PropertyGroup>
<_NS>
<Namespace Prefix="im" Uri="http://schemas.microsoft.com/VisualStudio/ImageManifestSchema/2014" />
</_NS>
<_FullAssemblyName>$(AssemblyName)%3bv$(StableVersion)%3bb03f5f7f11d50a3a</_FullAssemblyName>
</PropertyGroup>
<XmlPoke XmlInputPath="$(IntermediateOutputPath)%(ImageManifest.Filename)%(Extension)"
Namespaces="$(_NS)"
Query="/im:ImageManifest/im:Symbols/im:String[@Name='AssemblyName']/@Value"
Value="$(_FullAssemblyName)" />
<ItemGroup>
<Content Include="$(IntermediateOutputPath)%(ImageManifest.Filename)%(ImageManifest.Extension)">
<IncludeInVSIX>true</IncludeInVSIX>
<VSIXSubPath>.</VSIXSubPath>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Target>
<PropertyGroup>
<CoreCompileDependsOn>
ExtractLambdasFromXaml;
_CompileImageManifest;
$(CoreCompileDependsOn)
</CoreCompileDependsOn>
</PropertyGroup>
</Project>