提交 399f4b3f 编写于 作者: J Jared Parsons

Reorganize the central build logic

The combination of the minified MSBuild syntax and Directory.Build.props
/ targets file will change when in the build process our central build
files are executed. For instance Imports.targets will now be run much
later in the build after Sdk.targets. Where before, when it manually
invkoed Sdk.targets it was able to run both before and after it.

To keep our build functioning the same way we need to move around some
of the logic within our build files so that it executes in the same
relative order as it did before
上级 749ad035
<!-- 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>
<Import Project="build\Targets\Settings.props" />
</Project>
<!-- 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>
<Import Project="build\Targets\Imports.targets" />
</Project>
<?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="'$(RoslynProjectType)' == 'UnitTest' OR '$(RoslynProjectType)' == 'UnitTestPortable'">
<PropertyGroup>
<_IsAnyUnitTest>true</_IsAnyUnitTest>
<_NeedRuntimeAssets>true</_NeedRuntimeAssets>
<CopyNuGetImplementations>true</CopyNuGetImplementations>
<OutputPath>$(OutputPath)UnitTests\$(MSBuildProjectName)\</OutputPath>
</PropertyGroup>
</When>
<When Condition="'$(RoslynProjectType)' == 'Vsix'">
<PropertyGroup>
<_CopyReferences>false</_CopyReferences>
<_NeedRuntimeAssets>true</_NeedRuntimeAssets>
<CopyNuGetImplementations>true</CopyNuGetImplementations>
<OutputPath>$(OutputPath)Vsix\$(MSBuildProjectName)\</OutputPath>
</PropertyGroup>
</When>
<When Condition="'$(RoslynProjectType)' == 'Custom'">
<!-- Do nothing -->
</When>
<When Condition="'$(RoslynProjectType)' == '' AND '$(OutputType)' == 'Library'">
<PropertyGroup>
<_CopyReferences>false</_CopyReferences>
<_CopyProjectReferences>false</_CopyProjectReferences>
<CopyNuGetImplementations>false</CopyNuGetImplementations>
<OutputPath>$(OutputPath)Dlls\$(MSBuildProjectName)\</OutputPath>
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
</PropertyGroup>
</When>
<When Condition="'$(RoslynProjectType)' == '' AND '$(OutputType)' == 'Exe'">
<PropertyGroup>
<_NeedRuntimeAssets>true</_NeedRuntimeAssets>
<CopyNuGetImplementations>true</CopyNuGetImplementations>
<OutputPath>$(OutputPath)Exes\$(MSBuildProjectName)\</OutputPath>
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
</PropertyGroup>
</When>
<When Condition="'$(RoslynProjectType)' == '' AND '$(OutputType)' == 'WinExe'">
<PropertyGroup>
<_NeedRuntimeAssets>true</_NeedRuntimeAssets>
<CopyNuGetImplementations>true</CopyNuGetImplementations>
<OutputPath>$(OutputPath)Exes\$(MSBuildProjectName)\</OutputPath>
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
</PropertyGroup>
</When>
</Choose>
<!--
DocumentationFile needs to be set before importing common targets.
C# common targets (unlike VB) prefix DocumentationFile path with IntermediateOutputPath. However, using that here does not work with multi-targeting as
the IntermediateOutputPath will not yet have the TargetFramework appended, which will lead to a race where parallel builds for different TargetFrameworks
attempt to write the doc xml to the same xml location. Instead, we can simply set GenerateDocumentationFile=true and let the SDK pick the correct path.
Ideally, we'd just use the same construct for VB here, but that is currently blocked by https://github.com/dotnet/sdk/issues/1598.
-->
<PropertyGroup Condition="'$(GenerateDocumentationFile)' == '' AND '$(DocumentationFile)' == '' AND '$(NoDocumentationFile)' != 'true' AND '$(AssemblyName)' != ''">
<DocumentationFile Condition="'$(ProjectLanguage)' == 'VB'">$(AssemblyName).xml</DocumentationFile>
<GenerateDocumentationFile Condition="'$(ProjectLanguage)' == 'CSharp'">true</GenerateDocumentationFile>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFrameworks)' != ''">
<IntermediateOutputPath>$(IntermediateOutputPath)$(TargetFramework.ToLowerInvariant())\</IntermediateOutputPath>
<OutputPath>$(OutputPath)$(TargetFramework.ToLowerInvariant())\</OutputPath>
</PropertyGroup>
<!-- If the project hasn't configured a ruleset, set a default ruleset. -->
<Choose>
<When Condition="'$(CodeAnalysisRuleSet)' == ''">
<Choose>
<!-- We have different default rulesets for Build versus Running Code Analysis. -->
<When Condition="'$(RunCodeAnalysis)' == 'true' OR '$(RunCodeAnalysisOnce)' == 'true'">
<PropertyGroup>
<DefaultRulesetSuffix>_RunCodeAnalysisRules</DefaultRulesetSuffix>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup>
<DefaultRulesetSuffix>_BuildRules</DefaultRulesetSuffix>
</PropertyGroup>
</Otherwise>
</Choose>
<PropertyGroup>
<CodeAnalysisRuleSet Condition="'$(CodeAnalysisRuleSet)' == '' AND '$(NonShipping)' == 'true'">$(MSBuildThisFileDirectory)..\Rulesets\NonShippingProject$(DefaultRulesetSuffix).ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleSet Condition="'$(CodeAnalysisRuleSet)' == '' AND '$(AnalyzerProject)' == 'true'">$(MSBuildThisFileDirectory)..\Rulesets\AnalyzerProject$(DefaultRulesetSuffix).ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleSet Condition="'$(CodeAnalysisRuleSet)' == ''">$(MSBuildThisFileDirectory)..\Rulesets\Roslyn$(DefaultRulesetSuffix).ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
</When>
</Choose>
<!--
If TargetNetFX20 is true the project targets Framework 2.0 reference assemblies provided by Microsoft.NetFX20 nuget package.
Use the latest Framework toolset to build, but set msbuild properties below
so to avoid 4.5 specific artifacts to be added to the compilation (references, attributes).
-->
<PropertyGroup Condition="'$(TargetNetFX20)' == 'true'">
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
<AddAdditionalExplicitAssemblyReferences>false</AddAdditionalExplicitAssemblyReferences>
<NoStdLib>true</NoStdLib>
<FrameworkPathOverride>$(NuGetPackageRoot)\Microsoft.NetFX20\$(MicrosoftNetFX20Version)\lib\net20</FrameworkPathOverride>
<ExecuteAsTool>false</ExecuteAsTool>
<GenerateResourceMSBuildRuntime>CurrentRuntime</GenerateResourceMSBuildRuntime>
</PropertyGroup>
</Project>
......@@ -2,66 +2,6 @@
<!-- 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 ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Choose>
<When Condition="'$(RoslynProjectType)' == 'UnitTest' OR '$(RoslynProjectType)' == 'UnitTestPortable'">
<PropertyGroup>
<_IsAnyUnitTest>true</_IsAnyUnitTest>
<_NeedRuntimeAssets>true</_NeedRuntimeAssets>
<CopyNuGetImplementations>true</CopyNuGetImplementations>
<OutputPath>$(OutputPath)UnitTests\$(MSBuildProjectName)\</OutputPath>
</PropertyGroup>
</When>
<When Condition="'$(RoslynProjectType)' == 'Vsix'">
<PropertyGroup>
<_CopyReferences>false</_CopyReferences>
<_NeedRuntimeAssets>true</_NeedRuntimeAssets>
<CopyNuGetImplementations>true</CopyNuGetImplementations>
<OutputPath>$(OutputPath)Vsix\$(MSBuildProjectName)\</OutputPath>
</PropertyGroup>
</When>
<When Condition="'$(RoslynProjectType)' == 'Custom'">
<!-- Do nothing -->
</When>
<When Condition="'$(RoslynProjectType)' == '' AND '$(OutputType)' == 'Library'">
<PropertyGroup>
<_CopyReferences>false</_CopyReferences>
<_CopyProjectReferences>false</_CopyProjectReferences>
<CopyNuGetImplementations>false</CopyNuGetImplementations>
<OutputPath>$(OutputPath)Dlls\$(MSBuildProjectName)\</OutputPath>
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
</PropertyGroup>
</When>
<When Condition="'$(RoslynProjectType)' == '' AND '$(OutputType)' == 'Exe'">
<PropertyGroup>
<_NeedRuntimeAssets>true</_NeedRuntimeAssets>
<CopyNuGetImplementations>true</CopyNuGetImplementations>
<OutputPath>$(OutputPath)Exes\$(MSBuildProjectName)\</OutputPath>
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
</PropertyGroup>
</When>
<When Condition="'$(RoslynProjectType)' == '' AND '$(OutputType)' == 'WinExe'">
<PropertyGroup>
<_NeedRuntimeAssets>true</_NeedRuntimeAssets>
<CopyNuGetImplementations>true</CopyNuGetImplementations>
<OutputPath>$(OutputPath)Exes\$(MSBuildProjectName)\</OutputPath>
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
</PropertyGroup>
</When>
</Choose>
<!--
DocumentationFile needs to be set before importing common targets.
C# common targets (unlike VB) prefix DocumentationFile path with IntermediateOutputPath. However, using that here does not work with multi-targeting as
the IntermediateOutputPath will not yet have the TargetFramework appended, which will lead to a race where parallel builds for different TargetFrameworks
attempt to write the doc xml to the same xml location. Instead, we can simply set GenerateDocumentationFile=true and let the SDK pick the correct path.
Ideally, we'd just use the same construct for VB here, but that is currently blocked by https://github.com/dotnet/sdk/issues/1598.
-->
<PropertyGroup Condition="'$(GenerateDocumentationFile)' == '' AND '$(DocumentationFile)' == '' AND '$(NoDocumentationFile)' != 'true' AND '$(AssemblyName)' != ''">
<DocumentationFile Condition="'$(ProjectLanguage)' == 'VB'">$(AssemblyName).xml</DocumentationFile>
<GenerateDocumentationFile Condition="'$(ProjectLanguage)' == 'CSharp'">true</GenerateDocumentationFile>
</PropertyGroup>
<PropertyGroup>
<RoslynPublicKey>0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9</RoslynPublicKey>
......@@ -82,8 +22,6 @@
<!-- The netstandard 1.3 package by default includes Microsoft.CodeAnalysis. That's a bit
of a non-starter since we build it. Using manual references for now -->
<DisableImplicitFrameworkReferences Condition="'$(DisableImplicitFrameworkReferences)' == ''" >true</DisableImplicitFrameworkReferences>
<AppendTargetFrameworkToOutputPath Condition="'$(TargetFrameworks)' == ''">false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
<!-- Only generate our runtimeconfig.json files for net core apps. It's unnecessary in desktop projects
but gets included in lots of output items like VSIX. -->
......@@ -96,31 +34,6 @@
</PropertyGroup>
<!-- If the project hasn't configured a ruleset, set a default ruleset. -->
<Choose>
<When Condition="'$(CodeAnalysisRuleSet)' == ''">
<Choose>
<!-- We have different default rulesets for Build versus Running Code Analysis. -->
<When Condition="'$(RunCodeAnalysis)' == 'true' OR '$(RunCodeAnalysisOnce)' == 'true'">
<PropertyGroup>
<DefaultRulesetSuffix>_RunCodeAnalysisRules</DefaultRulesetSuffix>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup>
<DefaultRulesetSuffix>_BuildRules</DefaultRulesetSuffix>
</PropertyGroup>
</Otherwise>
</Choose>
<PropertyGroup>
<CodeAnalysisRuleSet Condition="'$(CodeAnalysisRuleSet)' == '' AND '$(NonShipping)' == 'true'">$(MSBuildThisFileDirectory)..\Rulesets\NonShippingProject$(DefaultRulesetSuffix).ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleSet Condition="'$(CodeAnalysisRuleSet)' == '' AND '$(AnalyzerProject)' == 'true'">$(MSBuildThisFileDirectory)..\Rulesets\AnalyzerProject$(DefaultRulesetSuffix).ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleSet Condition="'$(CodeAnalysisRuleSet)' == ''">$(MSBuildThisFileDirectory)..\Rulesets\Roslyn$(DefaultRulesetSuffix).ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
</When>
</Choose>
<!-- Settings for localization -->
<ItemGroup>
<PackageReference Include="XliffTasks" Version="$(XliffTasksVersion)" PrivateAssets="All" Condition="'$(NonShipping)' != 'true'" />
......@@ -208,8 +121,6 @@
</SuggestedBindingRedirects>
</ItemGroup>
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />
<!-- It looks like MSBuild has a bug on *nix where they aggressively
directory separators from '\'to '/', even when the '\'
is being used as an escape character in a define constant in VB.
......
......@@ -136,6 +136,8 @@
<EnableSourceLink Condition="'$(DeveloperBuild)' != 'true'">true</EnableSourceLink>
<EnableDefaultNoneItems>false</EnableDefaultNoneItems>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
<!-- It is only intended to automatically run update during dev cycle. However, It will fail the build on CI if the XLF file is not updated.
XLF file should be checked in and loc team will update the XLF it with translated version.
......@@ -165,20 +167,6 @@
<VisualStudioBuildToolsVersion Condition="'$(IsDev14VsiBuild)' == 'true'">14.3.25420</VisualStudioBuildToolsVersion>
</PropertyGroup>
<!--
If TargetNetFX20 is true the project targets Framework 2.0 reference assemblies provided by Microsoft.NetFX20 nuget package.
Use the latest Framework toolset to build, but set msbuild properties below
so to avoid 4.5 specific artifacts to be added to the compilation (references, attributes).
-->
<PropertyGroup Condition="'$(TargetNetFX20)' == 'true'">
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
<AddAdditionalExplicitAssemblyReferences>false</AddAdditionalExplicitAssemblyReferences>
<NoStdLib>true</NoStdLib>
<FrameworkPathOverride>$(NuGetPackageRoot)\Microsoft.NetFX20\$(MicrosoftNetFX20Version)\lib\net20</FrameworkPathOverride>
<ExecuteAsTool>false</ExecuteAsTool>
<GenerateResourceMSBuildRuntime>CurrentRuntime</GenerateResourceMSBuildRuntime>
</PropertyGroup>
<PropertyGroup Condition="'$(DevEnvDir)' == ''">
<DevEnvDir>$([System.Environment]::ExpandEnvironmentVariables("%VS$(VisualStudioReferenceMajorVersion)0COMNTOOLS%"))</DevEnvDir>
<DevEnvDir>$(DevEnvDir)\..\IDE</DevEnvDir>
......@@ -211,8 +199,6 @@
AssemblyFile="$(NuGetPackageRoot)\Roslyn.Build.Util\$(RoslynBuildUtilVersion)\lib\net46\Roslyn.MSBuild.Util.dll"
Condition="'$(OS)' == 'Windows_NT'" />
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
<Import Project="$(RoslynDiagnosticsPropsFilePath)" Condition="'$(UseRoslynAnalyzers)' == 'true' AND Exists('$(RoslynDiagnosticsPropsFilePath)')" />
<ImportGroup Label="WindowsImports" Condition="'$(OS)' == 'Windows_NT'">
......
......@@ -10,6 +10,8 @@
<OutputPath>$(OutputPath)Vsix\CodeAnalysisCompilers</OutputPath>
<IsPackage>true</IsPackage>
<OutputType>vsix</OutputType>
<ImportDirectoryBuildProps>false</ImportDirectoryBuildProps>
<ImportDirectoryBuildTargets>false</ImportDirectoryBuildTargets>
</PropertyGroup>
<Import Project="$(NuGetPackageRoot)\MicroBuild.Core\$(MicroBuildCoreVersion)\build\MicroBuild.Core.props" />
......
......@@ -10,6 +10,8 @@
<IsPackage>true</IsPackage>
<FinalizeValidate>false</FinalizeValidate>
<ValidateManifest>false</ValidateManifest>
<ImportDirectoryBuildProps>false</ImportDirectoryBuildProps>
<ImportDirectoryBuildTargets>false</ImportDirectoryBuildTargets>
</PropertyGroup>
<Import Project="$(NuGetPackageRoot)\MicroBuild.Core\$(MicroBuildCoreVersion)\build\MicroBuild.Core.props" />
......
......@@ -10,6 +10,8 @@
<IsPackage>true</IsPackage>
<FinalizeValidate>false</FinalizeValidate>
<ValidateManifest>false</ValidateManifest>
<ImportDirectoryBuildProps>false</ImportDirectoryBuildProps>
<ImportDirectoryBuildTargets>false</ImportDirectoryBuildTargets>
</PropertyGroup>
<Import Project="$(NuGetPackageRoot)\MicroBuild.Core\$(MicroBuildCoreVersion)\build\MicroBuild.Core.props" />
......
......@@ -9,6 +9,8 @@
<OutputPath>$(OutputPath)\Vsix\PortableFacades</OutputPath>
<IsPackage>true</IsPackage>
<OutputType>vsix</OutputType>
<ImportDirectoryBuildProps>false</ImportDirectoryBuildProps>
<ImportDirectoryBuildTargets>false</ImportDirectoryBuildTargets>
</PropertyGroup>
<Import Project="$(NuGetPackageRoot)\MicroBuild.Core\$(MicroBuildCoreVersion)\build\MicroBuild.Core.props" />
......
......@@ -10,6 +10,8 @@
<IsPackage>true</IsPackage>
<FinalizeValidate>false</FinalizeValidate>
<ValidateManifest>false</ValidateManifest>
<ImportDirectoryBuildProps>false</ImportDirectoryBuildProps>
<ImportDirectoryBuildTargets>false</ImportDirectoryBuildTargets>
</PropertyGroup>
<Import Project="$(NuGetPackageRoot)\MicroBuild.Core\$(MicroBuildCoreVersion)\build\MicroBuild.Core.props" />
......
using System;
internal static class Program
{
internal static void Main()
{
throw new Exception("This should not be run");
}
}
......@@ -13,6 +13,7 @@
<TargetFramework>net461</TargetFramework>
<RuntimeIdentifier>$(RoslynDesktopRuntimeIdentifier)</RuntimeIdentifier>
<RoslynProjectType>UnitTest</RoslynProjectType>
<RootNamespace></RootNamespace>
</PropertyGroup>
<ItemGroup Label="Project References">
<ProjectReference Include="..\..\Compilers\Core\Portable\CodeAnalysis.csproj" />
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册