Imports.targets 21.2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <!-- Copyright (c)  Microsoft.  All Rights Reserved.  Licensed under the Apache License, Version 2.0.  See License.txt in the project root for license information. -->

  <Choose>
    <When Condition="'$(RoslynProjectType)' == 'ExeCoreClr'">
      <PropertyGroup>
        <_CopyReferences>false</_CopyReferences>
        <OutDir>$(OutDir)Exes\$(MSBuildProjectName)\</OutDir>
      </PropertyGroup>
    </When>
    <When Condition="'$(RoslynProjectType)' == 'UnitTest'">
      <PropertyGroup>
        <OutDir>$(OutDir)UnitTests\Current\</OutDir>
      </PropertyGroup>
    </When>
    <When Condition="'$(RoslynProjectType)' == 'UnitTestNext'">
      <PropertyGroup>
        <OutDir>$(OutDir)UnitTests\Next\</OutDir>
      </PropertyGroup>
    </When>
    <When Condition="'$(RoslynProjectType)' == 'CompilerGeneratorTool'">
      <PropertyGroup>
        <_CopyReferences>false</_CopyReferences>
        <OutDir>$(OutDir)Exes\</OutDir>
      </PropertyGroup>
    </When>
    <When Condition="'$(RoslynProjectType)' == 'DeploymentCompilerGeneratorTools'">
      <PropertyGroup>
        <OutDir>$(OutDir)CompilerGeneratorTools\</OutDir>
      </PropertyGroup>
    </When>
    <When Condition="'$(RoslynProjectType)' == 'Deployment'">
      <PropertyGroup>
        <OutDir>$(OutDir)Deployment\$(MSBuildProjectName)\</OutDir>
      </PropertyGroup>
    </When>
    <When Condition="'$(RoslynProjectType)' == 'Vsix'">
      <PropertyGroup>
        <_CopyReferences>false</_CopyReferences>
        <OutDir>$(OutDir)Vsix\$(MSBuildProjectName)\</OutDir>
      </PropertyGroup>
    </When>
    <When Condition="'$(RoslynProjectType)' == 'Dependency'">
      <!-- Thinking through these -->
      <PropertyGroup>
        <OutDir>$(OutDir)Ignore\$(MSBuildProjectName)\</OutDir>
      </PropertyGroup>
    </When>
    <When Condition="'$(RoslynProjectType)' == 'Custom'">
      <!-- Do nothing -->
    </When>
    <When Condition="'$(RoslynProjectType)' == '' and '$(OutputType)' == 'Library'">
      <PropertyGroup>
        <_CopyReferences>false</_CopyReferences>
        <_CopyProjectReferences>false</_CopyProjectReferences>
        <OutDir>$(OutDir)Dlls\$(MSBuildProjectName)\</OutDir>
      </PropertyGroup>
    </When>
    <When Condition="'$(RoslynProjectType)' == '' and '$(OutputType)' == 'Exe'">
      <PropertyGroup>
        <OutDir>$(OutDir)Exes\$(MSBuildProjectName)\</OutDir>
      </PropertyGroup>
    </When>
    <When Condition="'$(RoslynProjectType)' == '' and '$(OutputType)' == 'WinExe'">
      <PropertyGroup>
        <OutDir>$(OutDir)Exes\$(MSBuildProjectName)\</OutDir>
      </PropertyGroup>
    </When>
  </Choose>

J
Jared Parsons 已提交
71 72 73 74 75 76 77 78 79 80 81 82
  <Choose>
    <When Condition="'$(TargetFrameworkIdentifier)' == '.NETPortable'">
      <PropertyGroup>
        <MSBuildTargetsFilePath>$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.$(MSBuildTargetsLanguageName).targets</MSBuildTargetsFilePath>
      </PropertyGroup>
    </When>
    <Otherwise>
      <PropertyGroup>
        <MSBuildTargetsFilePath>$(MSBuildToolsPath)\Microsoft.$(MSBuildTargetsLanguageName).targets</MSBuildTargetsFilePath>
      </PropertyGroup>
    </Otherwise>
  </Choose>
83 84 85 86 87 88 89 90 91 92 93 94

  <PropertyGroup>
    <OutputPath>$(OutDir)</OutputPath>
    <DocumentationFile Condition="'$(DocumentationFile)' == '' AND '$(NoDocumentationFile)' != 'true' AND '$(Nonshipping)' != 'true' AND '$(ProjectLanguage)' == 'VB' AND '$(AssemblyName)' != ''">$(AssemblyName).xml</DocumentationFile>
    <DocumentationFile Condition="'$(DocumentationFile)' == '' AND '$(NoDocumentationFile)' != 'true' AND '$(Nonshipping)' != 'true' AND '$(ProjectLanguage)' == 'CSharp' AND '$(AssemblyName)' != ''">$(BaseIntermediateOutputPath)$(AssemblyName).xml</DocumentationFile>
    <RoslynPublicKey>0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9</RoslynPublicKey>
    <RoslynInternalKey>002400000480000094000000060200000024000052534131000400000100010055e0217eb635f69281051f9a823e0c7edd90f28063eb6c7a742a19b4f6139778ee0af438f47aed3b6e9f99838aa8dba689c7a71ddb860c96d923830b57bbd5cd6119406ddb9b002cf1c723bf272d6acbb7129e9d6dd5a5309c94e0ff4b2c884d45a55f475cd7dba59198086f61f5a8c8b5e601c0edbf269733f6f578fc8579c2</RoslynInternalKey>

    <!-- While UseCommonOutputDirectory will prevent NuGet implementations from being copied, 
         we still need to turn off CopyNuGetImplementations to prevent the build task from complaining about a 
         lack of a runtime section in our project.json. -->
    <CopyNuGetImplementations Condition="'$(UseCommonOutputDirectory)' == 'true'">false</CopyNuGetImplementations>
J
Jared Parsons 已提交
95 96 97

    <ForceGenerationOfBindingRedirects Condition="'$(GenerateMSBuildBindingRedirects)' == 'true'">true</ForceGenerationOfBindingRedirects>
    <AutoGenerateBindingRedirects Condition="'$(ForceGenerationOfBindingRedirects)' == 'true'">true</AutoGenerateBindingRedirects>
98

J
Jared Parsons 已提交
99 100 101 102
    <FileAlignment>512</FileAlignment>
    <HighEntropyVA>true</HighEntropyVA>
    <Deterministic>True</Deterministic>

103
    <OptimizationDataFolderPath>$(NuGetPackageRoot)\RoslynDependencies.OptimizationData\2.0.0-rc-61101-16\content\OptimizationData</OptimizationDataFolderPath>
J
Jared Parsons 已提交
104 105
    <OptimizationDataFile>$([System.IO.Path]::GetFullPath('$(OptimizationDataFolderPath)\$(TargetName).pgo'))</OptimizationDataFile>

J
Jared Parsons 已提交
106 107 108 109
    <GetVsixSourceItemsDependsOn>$(GetVsixSourceItemsDependsOn);IncludeVsixLocalOnlyItems</GetVsixSourceItemsDependsOn>
    <GetVsixSourceItemsDependsOn>$(GetVsixSourceItemsDependsOn);IncludeNuGetResolvedAssets</GetVsixSourceItemsDependsOn>
    <ProducingSignedVsix Condition="'$(ShouldSignBuild)' == 'true' AND '$(NonShipping)' != 'true' AND '$(CreateVsixContainer)' == 'true'">true</ProducingSignedVsix>
  </PropertyGroup>
J
Jared Parsons 已提交
110

111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
  <!-- 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>
J
Jared Parsons 已提交
129 130 131
        <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>
132 133 134 135 136 137 138 139 140 141 142 143
      </PropertyGroup>
    </When>
  </Choose>

  <!-- Settings for strong name signing -->
  <Choose>
    <When Condition="'$(SignAssembly)' == 'true'">
      <Choose>
        <!-- Shipping binaries are always public signed.  In the case of an official build $(OfficialBuild) the 
             binaries will be real signed as a post processing step. -->
        <When Condition="'$(NonShipping)' != 'true'">
          <PropertyGroup>
J
Jared Parsons 已提交
144
            <AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)..\Strong Name Keys\35MSSharedLib1024.snk</AssemblyOriginatorKeyFile>
145 146 147 148 149 150 151 152 153
            <PublicKey>$(RoslynPublicKey)</PublicKey>
            <PublicKeyToken>31BF3856AD364E35</PublicKeyToken>
            <PublicSign>true</PublicSign>
          </PropertyGroup>
        </When>

        <!-- Non-shipping binaries are simply signed with the Roslyn internal key. -->
        <Otherwise>
          <PropertyGroup>
J
Jared Parsons 已提交
154
            <AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)..\Strong Name Keys\RoslynInternalKey.Private.snk</AssemblyOriginatorKeyFile>
155 156 157 158 159 160 161 162 163
            <DelaySign>false</DelaySign>
            <PublicKey>$(RoslynInternalKey)</PublicKey>
            <PublicKeyToken>fc793a00266884fb</PublicKeyToken>
          </PropertyGroup>
        </Otherwise>
      </Choose>
    </When>
  </Choose>

J
Jared Parsons 已提交
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181
  <ItemDefinitionGroup Condition="'$(_CopyReferences)' == 'false'">
    <Reference>
      <Private>False</Private>
    </Reference>
  </ItemDefinitionGroup>

  <ItemDefinitionGroup Condition="'$(_CopyProjectReferences)' == 'false'">
    <ProjectReference>
      <Private>False</Private>
    </ProjectReference>
  </ItemDefinitionGroup>

  <ItemDefinitionGroup>
    <NuGetPackageToIncludeInVsix>
      <Visible>false</Visible>
    </NuGetPackageToIncludeInVsix>
  </ItemDefinitionGroup>

182 183 184 185 186 187
  <!-- ====================================================================================

         Generation of binding redirects.

       ==================================================================================== -->
  <ItemGroup Condition="'$(GenerateMSBuildBindingRedirects)' == 'true'">
J
Jared Parsons 已提交
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202
    <SuggestedBindingRedirects Include="Microsoft.Build, Version=$(VisualStudioReferenceAssemblyVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
      <MaxVersion>$(VisualStudioReferenceAssemblyVersion)</MaxVersion>
    </SuggestedBindingRedirects>
    <SuggestedBindingRedirects Include="Microsoft.Build.Engine, Version=$(VisualStudioReferenceAssemblyVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
      <MaxVersion>$(VisualStudioReferenceAssemblyVersion)</MaxVersion>
    </SuggestedBindingRedirects>
    <SuggestedBindingRedirects Include="Microsoft.Build.Framework, Version=$(VisualStudioReferenceAssemblyVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
      <MaxVersion>$(VisualStudioReferenceAssemblyVersion)</MaxVersion>
    </SuggestedBindingRedirects>
    <SuggestedBindingRedirects Include="Microsoft.Build.Tasks.$(MSBuildAssemblyNameFragment), Version=$(VisualStudioReferenceAssemblyVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
      <MaxVersion>$(VisualStudioReferenceAssemblyVersion)</MaxVersion>
    </SuggestedBindingRedirects>
    <SuggestedBindingRedirects Include="Microsoft.Build.Utilities.Core, Version=$(VisualStudioReferenceAssemblyVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
      <MaxVersion>$(VisualStudioReferenceAssemblyVersion)</MaxVersion>
    </SuggestedBindingRedirects>
203 204 205 206 207
  </ItemGroup>

  <Import Project="$(MSBuildTargetsFilePath)" />

  <!-- On Mono on *nix the NuGet targets aren't imported by default, so we do that here -->
J
Jared Parsons 已提交
208
  <Import Project="$(MSBuildExtensionsPath)\Microsoft\NuGet\Microsoft.NuGet.targets" Condition="'$(OS)' != 'Windows_NT'" />
209 210

  <Choose>
J
Jared Parsons 已提交
211
    <When Condition="'$(TargetFrameworkIdentifier)' == '.NETPortable' AND '$(TargetFrameworkVersion)' == 'v5.0'">
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237
      <!-- Treat portable exes as CoreClr-targeting-exes -->
      <PropertyGroup Condition="'$(OutputType)' == 'Exe'">
        <NuGetTargetMoniker>.NETCoreApp,Version=v1.0</NuGetTargetMoniker>
        <BaseNuGetRuntimeIdentifier Condition="'$(OS)' == 'Windows_NT'">win7</BaseNuGetRuntimeIdentifier>
      </PropertyGroup>

      <!-- Upgrade portable projects to .NETStandard 1.3 -->
      <PropertyGroup Condition="'$(OutputType)' == 'Library'">
        <NuGetTargetMoniker>.NETStandard,Version=v1.3</NuGetTargetMoniker>
      </PropertyGroup>
    </When>
  </Choose>

  <!-- 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.
       This change works around the bug by removing all quotes from
       define constants after Microsoft.VisualBasic.CurrentVersion adds
       them in our build. This should be OK since none of our constants
       should require quoting. See https://github.com/Microsoft/msbuild/issues/137 -->
  <PropertyGroup Condition="'$(OS)' != 'Windows_NT'">
    <FinalDefineConstants>$(FinalDefineConstants.Replace('"', ''))</FinalDefineConstants>
  </PropertyGroup>

  <!-- For our projects that specify multiple targets in the project.json to work around https://github.com/dotnet/roslyn/issues/12458,
       we need to also silence a NuGet generated warning -->
J
Jared Parsons 已提交
238 239
  <Target Name="EmitMSBuildWarning">
  </Target>
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254

  <Target Name="IncludeVsixLocalOnlyItems">
    <!-- This is shamelessly ripped from Microsoft.VsSDK.targets -->
    <ItemGroup>
      <VSIXSourceItemLocalOnly Include="@(Content)" Condition="'%(Content.IncludeInVSIXLocalOnly)'=='true' AND '%(Content.VSIXSubPath)'==''">
        <!-- Sets VSIXSubPath for content items that are nonlinked files -->
        <VSIXSubPath Condition="'%(Content.Link)'==''">%(Content.RelativeDir)</VSIXSubPath>
        <!-- Sets VSIXSubPath for content items that are linked files -->
        <VSIXSubPath Condition="'%(Content.Link)'!=''">$([System.IO.Path]::GetDirectoryName(%(Content.Link)))</VSIXSubPath>
      </VSIXSourceItemLocalOnly>

      <VSIXSourceItemLocalOnly Include="@(Content)" Condition="'%(Content.IncludeInVSIXLocalOnly)'=='true' AND '%(Content.VSIXSubPath)'!=''" />
    </ItemGroup>
  </Target>

J
Jared Parsons 已提交
255
  <!-- Include some of our NuGet-consumed assets into VSIX projects
256

J
Jared Parsons 已提交
257
       This exists for two reasons:
258

J
Jared Parsons 已提交
259 260 261 262 263 264
       1) In some cases, we need to include the contents of a NuGet package that is otherwise
          contained within the SuppressFromVsix list, because we're actually the component
          inside Visual Studio that ships that component
       
       2) The SDK targets don't currently look at the ReferenceCopyLocalPaths produced
          by the NuGet build task. -->
265 266 267 268 269 270 271 272 273 274 275 276 277 278

  <Target Name="IncludeNuGetResolvedAssets" DependsOnTargets="ResolveNuGetPackageAssets" Condition="'@(NuGetPackageToIncludeInVsix)' != ''">
    <ItemGroup>
      <_ReferenceCopyLocalPathsWithPotentialInclusions Include="@(ReferenceCopyLocalPaths)">
        <NuGetPackageToIncludeInVsix>%(NuGetPackageToIncludeInVsix.Identity)</NuGetPackageToIncludeInVsix>
      </_ReferenceCopyLocalPathsWithPotentialInclusions>

      <VSIXCopyLocalReferenceSourceItem Include="@(_ReferenceCopyLocalPathsWithPotentialInclusions)"
        Condition="'%(_ReferenceCopyLocalPathsWithPotentialInclusions.NuGetPackageId)' == '%(_ReferenceCopyLocalPathsWithPotentialInclusions.NuGetPackageToIncludeInVsix)' and
                   '%(_ReferenceCopyLocalPathsWithPotentialInclusions.Extension)' != '.pdb'">
        <ForceIncludeInVsix>true</ForceIncludeInVsix>
        <Private>true</Private>
      </VSIXCopyLocalReferenceSourceItem>
    </ItemGroup>
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294
  </Target>

  <ItemDefinitionGroup>
    <NuGetPackageToIncludeInVsix>
      <Visible>false</Visible>
    </NuGetPackageToIncludeInVsix>
  </ItemDefinitionGroup>

  <!-- Currently, the Willow installer can't install vsixes that have a <Prerequisites> element
       but the Dev15 RC SDK packages can NOT install vsixes without them as part of the build.
       To work around this conflict, we include them in our manifest files, but if we're building
       with something older than Dev15 RC (as we do for official builds that we insert into setup)
       we'll run a transform to strip out the <Prerequisites> element. -->
  <Target Name="RewriteVsixManifestOnOfficialBuild"
          BeforeTargets="FindSourceVsixManifest"
          Condition="'$(IsDev15RC)' != 'true'">
295
    <MakeDir Directories="$(IntermediateOutputPath)" />
296 297
    <XslTransformation XslInputPath="$(MSBuildThisFileDirectory)TransformVsixManifest.xslt"
                       XmlInputPaths="source.extension.vsixmanifest"
298
                       OutputPaths="$(IntermediateOutputPath)\source.extension.vsixmanifest" />
299
    <ItemGroup>
300 301 302
      <!-- Note that `FindSourceVsixManifest` finds the first item in @None that matches the name.
           Our template projects include other manifests as content that are in @None, so make
           sure we put our tranformed item back at the beginning of the list. -->
303
      <None Remove="source.extension.vsixmanifest" />
304 305
      <_TempNoneForReordering Include="@(None)" />
      <None Remove="@(None)" />
306
      <None Include="$(IntermediateOutputPath)\source.extension.vsixmanifest;@(_TempNoneForReordering)" />
307
    </ItemGroup>
308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336
  </Target>

  <!-- This is a copy of the Microsoft.VisualStudio.SDK.EmbedInteropTypes NuGet package, but only the list of
       assemblies that we need. The package includes things like EnvDTE which are reasonable for consumers, but
       strange since we actually _implement_ DTE and use it as an exchange type with generics in a few places. -->
  <Target Name="LinkVSSDKEmbeddableAssemblies" DependsOnTargets="ResolveReferences" AfterTargets="ResolveReferences">
    <ItemGroup>
      <ReferencePath Condition="
              '%(FileName)' == 'Microsoft.VisualStudio.Shell.Embeddable'
           or '%(FileName)' == 'Microsoft.VisualStudio.Shell.Interop.12.0'
           or '%(FileName)' == 'Microsoft.VisualStudio.Shell.Interop.12.1.DesignTime'
           or '%(FileName)' == 'Microsoft.VisualStudio.Shell.Interop.14.0.DesignTime'
           or '%(FileName)' == 'Microsoft.VisualStudio.Shell.Interop.15.0.DesignTime'
           or '%(Filename)' == 'Microsoft.VisualStudio.Imaging.Interop.14.0.DesignTime'
           or '%(FileName)' == 'Microsoft.VisualStudio.TextManager.Interop.12.1.DesignTime'
           or '%(FileName)' == 'Microsoft.Internal.VisualStudio.Shell.Interop.14.0.DesignTime'
           or '%(FileName)' == 'Microsoft.VisualStudio.ProjectSystem.Interop'
           or '%(FileName)' == 'stdole'
           or '%(FileName)' == 'Microsoft.VisualStudio.CommandBars'
              ">
        <EmbedInteropTypes>true</EmbedInteropTypes>
      </ReferencePath>
    </ItemGroup>
  </Target>

  <Import Project="GenerateAssemblyInfo.targets" Condition="'$(ProjectLanguage)' == 'CSharp' OR '$(ProjectLanguage)' == 'VB'" />
  <Import Project="GenerateInternalsVisibleTo.targets" />
  <Import Project="GenerateCompilerInternals.targets" />

J
Jared Parsons 已提交
337 338 339 340
  <ImportGroup Condition="'$(ImportVSSDKTargets)' == 'true'">
    <Import Project="$(NuGetPackageRoot)\Microsoft.VSSDK.BuildTools\$(VisualStudioBuildToolsVersion)\build\Microsoft.VsSDK.BuildTools.targets" />
    <Import Project="$(VSToolsPath)\VSSDK\Microsoft.VsSDK.targets" />
  </ImportGroup>
341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370

  <!-- ====================================================================================

         Support for in-place modification of the compiled binary.
         Since there may be more than one post compile modification, we must take care not
         to break incremental builds. A timestemp file is written out when all modification
         targets have completed.
         Note that the targets participating in post compile modification must list the
         sentinel file as one of their outputs, but they should not modify it.

       ==================================================================================== -->

  <PropertyGroup>
    <PostCompileBinaryModificationSentinelFile>$(IntermediateOutputPath)$(TargetFileName).pcbm</PostCompileBinaryModificationSentinelFile>
  </PropertyGroup>

  <Target Name="PostCompileBinaryModification"
          AfterTargets="CoreCompile"
          DependsOnTargets="ApplyOptimizations"
          Inputs="@(IntermediateAssembly)"
          Outputs="@(IntermediateAssembly);$(PostCompileBinaryModificationSentinelFile)">

    <!-- Write out a sentinel timestamp file to prevent unnecessary work in incremental builds. -->
    <Touch AlwaysCreate="true" Files="$(PostCompileBinaryModificationSentinelFile)" />

    <ItemGroup>
      <FileWrites Include="$(PostCompileBinaryModificationSentinelFile)" />
    </ItemGroup>
  </Target>

J
Jared Parsons 已提交
371
  <!-- Support for rolling optimization data into assemblies. -->
J
Jared Parsons 已提交
372 373 374 375 376 377 378 379 380 381
  <Target Name="ForceGenerationOfBindingRedirects"
          AfterTargets="ResolveAssemblyReferences"
          BeforeTargets="GenerateBindingRedirects"
          Condition="'$(ForceGenerationOfBindingRedirects)' == 'true'">

    <PropertyGroup>
      <!-- Needs to be set in a target because it has to be set after the initial evaluation in the common targets -->
      <GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
    </PropertyGroup>
  </Target>
382

J
Jared Parsons 已提交
383 384
  <!-- The path to IBCMerge.exe must be specified at build time via $(IbcMergePath).  Typically this is passed as a 
       build definition variable -->
385 386 387 388 389 390 391 392 393 394 395 396 397
  <Target Name="ApplyOptimizations"
          Condition="'$(OfficialBuild)' == 'true' AND '$(NonShipping)' != 'true' AND '$(SkipApplyOptimizations)' != 'true' AND Exists('$(OptimizationDataFile)') AND Exists('$(IbcMergePath)')"
          Inputs="@(IntermediateAssembly)"
          Outputs="@(IntermediateAssembly);$(PostCompileBinaryModificationSentinelFile)">

      <Message Text="Adding optimization data to @(IntermediateAssembly)" />
      <Exec Command="&quot;$(IbcMergePath)&quot; -q -f -partialNGEN -minify -mo &quot;@(IntermediateAssembly)&quot; -incremental &quot;$(OptimizationDataFile)&quot;"
            ConsoleToMSBuild="true">
        <Output TaskParameter="ConsoleOutput" PropertyName="IbcMergeOutput" />
      </Exec>
      <Message Text="$(IbcMergeOutput)" />

  </Target>
J
Jared Parsons 已提交
398 399 400

  <!-- Returns the current build version. Used in .vsixmanifests to substitute our build version into them -->
  <Target Name="GetBuildVersion" Outputs="$(VsixVersion)" />
401
</Project>