提交 3863dbaf 编写于 作者: T Tomáš Matoušek 提交者: Jared Parsons

Move ILAsm publishing to ILAsmDeploy project (#30346)

* Move ILAsm publishing to ILAsmDeploy project

* BuildBoss: recognize ReferenceOutputAssembly attribute

* Add GlobalPropertiesToRemove
上级 81ab2013
......@@ -65,7 +65,7 @@
identifier to the end of the output path
https://github.com/dotnet/roslyn/issues/23547
-->
<PublishDir Condition="'$(PublishDir)' != '' AND '$(RuntimeIdentifier)' != ''">$(OutputPath)$(RuntimeIdentifier)\$(PublishDirName)\</PublishDir>
<PublishDir Condition="'$(PublishDir)' != '' AND '$(RuntimeIdentifier)' != '' AND '$(MSBuildProjectName)' != 'IlAsmDeploy'">$(OutputPath)$(RuntimeIdentifier)\$(PublishDirName)\</PublishDir>
<PublishDir Condition="'$(PublishDir)' != '' AND '$(RuntimeIdentifier)' == ''">$(OutputPath)$(TargetFramework)\$(PublishDirName)\</PublishDir>
<DocumentationFile Condition="'$(GenerateDocumentationFile)' == 'true' AND '$(Language)' == 'VB'">$(AssemblyName).xml</DocumentationFile>
......
......@@ -12,18 +12,24 @@
<RootNamespace></RootNamespace>
<DisableImplicitFrameworkReferences>false</DisableImplicitFrameworkReferences>
<IsShipping>false</IsShipping>
<!--
Directory where to deploy ILAsm when targeting .NET Core app.
IlasmUtilities relies on ILAsm being deployed to this location.
-->
<IlasmPublishDir>$(ArtifactsDir)Tools\ILAsm\</IlasmPublishDir>
</PropertyGroup>
<ItemGroup Label="Project References">
<ProjectReference Include="..\..\..\Compilers\Test\Resources\Core\Microsoft.CodeAnalysis.Compiler.Test.Resources.csproj" />
<ProjectReference Include="..\..\..\Compilers\Core\Portable\Microsoft.CodeAnalysis.csproj" />
<ProjectReference Include="..\..\..\Compilers\CSharp\Portable\Microsoft.CodeAnalysis.CSharp.csproj" />
<ProjectReference Include="..\..\..\Compilers\VisualBasic\Portable\Microsoft.CodeAnalysis.VisualBasic.vbproj" />
<!--
Reference ILAsm deploy project to make sure it's built since we need its outputs, but not reference the outputs themselves.
Note SkipGetTargetFrameworkProperties makes it possible to reference project with incompatible TFM.
GlobalPropertiesToRemove makes sure TargetFramework isn't set as a global property for the target project.
-->
<ProjectReference Include="..\..\..\Tools\ILAsm\IlAsmDeploy.csproj"
ReferenceOutputAssembly="false"
SkipGetTargetFrameworkProperties="true"
GlobalPropertiesToRemove="TargetFramework"
Condition="'$(TargetFramework)' == 'netcoreapp2.1'" />
</ItemGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'" />
......@@ -111,6 +117,4 @@
<ItemGroup Condition="'$(TargetFramework)' == 'net46'">
<PackageReference Include="ICSharpCode.Decompiler" Version="$(ICSharpCodeDecompilerVersion)" />
</ItemGroup>
<Import Project="..\..\..\Tools\ILAsm\DeployILAsm.targets"/>
</Project>
\ No newline at end of file
......@@ -184,10 +184,10 @@ internal List<ProjectReferenceEntry> GetDeclaredProjectReferences()
{
// Make sure to check for references that exist only for ordering purposes. They don't count as
// actual references.
var refOutputAssembly = r.Element(Namespace.GetName("ReferenceOutputAssembly"));
if (refOutputAssembly != null)
var referenceOutputAssemblyValue = r.Element(Namespace.GetName("ReferenceOutputAssembly"))?.Value ?? r.Attribute(XName.Get("ReferenceOutputAssembly"))?.Value;
if (referenceOutputAssemblyValue != null)
{
if (bool.TryParse(refOutputAssembly.Value.Trim().ToLower(), out var isRealReference) && !isRealReference)
if (bool.TryParse(referenceOutputAssemblyValue.Trim().ToLower(), out var isRealReference) && !isRealReference)
{
continue;
}
......
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -->
<Project>
<Choose>
<When Condition="'$(OS)' == 'Windows_NT'">
<PropertyGroup>
<_IlasmRid>win-x64</_IlasmRid>
</PropertyGroup>
</When>
<When Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true'">
<PropertyGroup>
<_IlasmRid>osx-x64</_IlasmRid>
</PropertyGroup>
</When>
<When Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true'">
<PropertyGroup>
<_IlasmRid>linux-x64</_IlasmRid>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup>
<_IlasmRid />
</PropertyGroup>
</Otherwise>
</Choose>
<PropertyGroup>
<_IlasmDeployProj>$(MSBuildThisFileDirectory)IlAsmDeploy.csproj</_IlasmDeployProj>
<_IlasmIncrementalBuildMarker>$(IlasmPublishDir).v$(MicrosoftNETCoreILAsmVersion)</_IlasmIncrementalBuildMarker>
</PropertyGroup>
<Target Name="_PublishILAsm"
AfterTargets="Build"
Inputs="$(MSBuildThisFileFullPath);$(_IlasmDeployProj)"
Outputs="$(_IlasmIncrementalBuildMarker)"
Condition="'$(TargetFramework)' == 'netcoreapp2.1'">
<Error Text="Unknown OS" Condition="'$(_IlasmRid)' == ''" />
<MSBuild Projects="$(_IlasmDeployProj)"
Targets="Publish"
Properties="SelfContained=true;RuntimeIdentifier=$(_IlasmRid);PublishDir=$(IlasmPublishDir)" />
<Touch Files="$(_IlasmIncrementalBuildMarker)" AlwaysCreate="true">
<Output TaskParameter="TouchedFiles" ItemName="FileWrites"/>
</Touch>
</Target>
</Project>
\ No newline at end of file
......@@ -3,15 +3,58 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<RuntimeIdentifiers>$(RoslynPortableRuntimeIdentifiers)</RuntimeIdentifiers>
<OutputType>Exe</OutputType>
<!--
When the project is published as a self-contained app do not require the latest runtime patch.
This is ok since the app is only used for testing.
-->
<TargetLatestRuntimePatch>false</TargetLatestRuntimePatch>
<SelfContained>true</SelfContained>
<!-- Do not build again when publishing -->
<NoBuild>true</NoBuild>
<PublishDir>$(ArtifactsDir)Tools\ILAsm\</PublishDir>
</PropertyGroup>
<Choose>
<When Condition="'$(OS)' == 'Windows_NT'">
<PropertyGroup>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
</PropertyGroup>
</When>
<When Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true'">
<PropertyGroup>
<RuntimeIdentifier>osx-x64</RuntimeIdentifier>
</PropertyGroup>
</When>
<When Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true'">
<PropertyGroup>
<RuntimeIdentifier>linux-x64</RuntimeIdentifier>
</PropertyGroup>
</When>
</Choose>
<ItemGroup>
<PackageReference Include="Microsoft.NETCore.ILAsm" Version="$(MicrosoftNETCoreILAsmVersion)" />
</ItemGroup>
<PropertyGroup>
<_IlasmIncrementalBuildMarker>$(PublishDir).v$(MicrosoftNETCoreILAsmVersion)</_IlasmIncrementalBuildMarker>
</PropertyGroup>
<Target Name="_PublishILAsm"
AfterTargets="Build"
Inputs="$(MSBuildThisFileFullPath)"
Outputs="$(_IlasmIncrementalBuildMarker)">
<Error Text="Unknown OS" Condition="'$(RuntimeIdentifier)' == ''" />
<MSBuild Projects="$(MSBuildThisFileFullPath)" Targets="Publish"/>
<Touch Files="$(_IlasmIncrementalBuildMarker)" AlwaysCreate="true">
<Output TaskParameter="TouchedFiles" ItemName="FileWrites"/>
</Touch>
</Target>
</Project>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册