VisualStudio.targets 5.9 KB
Newer Older
T
Tomáš Matoušek 已提交
1 2 3 4 5 6 7
<?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>
  <PropertyGroup>
    <GetVsixSourceItemsDependsOn>$(GetVsixSourceItemsDependsOn);IncludeVsixLocalOnlyItems</GetVsixSourceItemsDependsOn>
    <GetVsixSourceItemsDependsOn>$(GetVsixSourceItemsDependsOn);IncludeNuGetResolvedAssets</GetVsixSourceItemsDependsOn>
    
T
Tomáš Matoušek 已提交
8 9 10 11 12 13
    <!-- 
      Transitive references get passed to all VS command line tools related to VSIX, VSCT, etc ... processsing. 
      These tools don't have RSP files and the full set of transitive references end up overflowing the allowed 
      command line length for Windows. These projects must manually specify references to avoid this overflow.
    -->
    <DisableTransitiveProjectReferences Condition="'$(IsVsixProject)' == 'true'">true</DisableTransitiveProjectReferences>
T
Tomáš Matoušek 已提交
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
  </PropertyGroup>

  <ItemDefinitionGroup>
    <VSIXSourceItem>
      <Visible>false</Visible>
    </VSIXSourceItem>
    
    <NuGetPackageToIncludeInVsix>
      <Visible>false</Visible>
    </NuGetPackageToIncludeInVsix>
  </ItemDefinitionGroup>
  
  <!-- CPS doesn't show these items by default, but we want to show them. -->
  <ItemGroup>
    <None Include="@(VSCTCompile)" />
  </ItemGroup>

  <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>

  <!-- Include some of our NuGet-consumed assets into VSIX projects

       This exists for two reasons:

       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. -->

  <Target Name="IncludeNuGetResolvedAssets" DependsOnTargets="ResolvePackageDependenciesForBuild" Condition="'@(NuGetPackageToIncludeInVsix)' != ''">

58 59 60 61 62 63 64 65 66 67 68 69 70 71
    <!-- Calculate a list of packages ReferenceCopyLocalPaths originate from whose content should not be included in the VSIX -->
    <ItemGroup>
      <_ExcludedPackageId Include="@(ReferenceCopyLocalPaths->'%(NuGetPackageId)')" />
      <_ExcludedPackageId Remove="@(NuGetPackageToIncludeInVsix)"/>
    </ItemGroup>

    <!-- Build a list assets to include in the VSIX keyed by package id -->
    <ItemGroup>
      <_AssetsByPackageId Include="@(ReferenceCopyLocalPaths->'%(NuGetPackageId)')">
        <Path>%(ReferenceCopyLocalPaths.Identity)</Path>
      </_AssetsByPackageId>

      <_AssetsByPackageId Remove="@(_ExcludedPackageId)" />
    </ItemGroup>
T
Tomáš Matoušek 已提交
72

73 74 75 76 77 78 79
    <!-- Update assets to mark those need to be optimized -->
    <ItemGroup>
      <_AssetsByPackageId Update="@(NuGetPackageToIncludeInVsix)">
        <Optimization Condition="'@(NuGetPackageToIncludeInVsix->'%(Optimization)')' == 'true'">true</Optimization>
      </_AssetsByPackageId>
    </ItemGroup>

80
    <!-- Include the assets in the VSIX -->
T
Tomáš Matoušek 已提交
81
    <ItemGroup>
82
      <VSIXCopyLocalReferenceSourceItem Include="@(_AssetsByPackageId->'%(Path)')">
T
Tomáš Matoušek 已提交
83 84
        <ForceIncludeInVsix>true</ForceIncludeInVsix>
        <Private>true</Private>
G
Gen Lu 已提交
85 86 87
        <Ngen Condition="'%(_AssetsByPackageId.Optimization)' == 'true'">true</Ngen>
        <NgenArchitecture Condition="'%(_AssetsByPackageId.Optimization)' == 'true'">All</NgenArchitecture>
        <NgenPriority Condition="'%(_AssetsByPackageId.Optimization)' == 'true'">3</NgenPriority>
T
Tomáš Matoušek 已提交
88 89 90 91
      </VSIXCopyLocalReferenceSourceItem>
    </ItemGroup>
  </Target>

92 93
  <!-- Microsoft.VisualStudio.SDK.EmbedInteropTypes sets a bunch of EmbedInteropTypes attributes, but Roslyn is somewhat special
       and has to do things differently. After the NuGet package does its thing, do further changes. -->
H
HeeJae Chang 已提交
94
  <Target Name="FixVSSDKEmbeddableAssemblies" AfterTargets="LinkVSSDKEmbeddableAssemblies" BeforeTargets="FindReferenceAssembliesForReferences">
T
Tomáš Matoušek 已提交
95
    <ItemGroup>
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
      <!-- The official NuGet package tries to embed EnvDTE, which is problematic because we implement the interfaces and use
           them in generic type parameters. Because of this, we can't embed them. -->
      <ReferencePath Condition="'%(FileName)' == 'EnvDTE80'
                             or '%(FileName)' == 'EnvDTE90'
                             or '%(FileName)' == 'EnvDTE100'">
        <EmbedInteropTypes>false</EmbedInteropTypes>
      </ReferencePath>

      <!-- The official NuGet package for Microsoft.VisualStudio.Shell.Design references this DLL in non-NoPIA way, so we can't embed it either -->
      <ReferencePath Condition="'%(FileName)' == 'Microsoft.VisualStudio.Designer.Interfaces'">
        <EmbedInteropTypes>false</EmbedInteropTypes>
      </ReferencePath>

      <!-- We reference Microsoft.VisualStudio.CodeAnalysis.Sdk.UI, which requires us to reference these DLLs non-NoPIA way -->
      <ReferencePath Condition="'%(FileName)' == 'Microsoft.VisualStudio.Shell.Interop.10.0'
                             or '%(FileName)' == 'Microsoft.VisualStudio.Shell.Interop.11.0'">
        <EmbedInteropTypes>false</EmbedInteropTypes>
T
Tomáš Matoušek 已提交
113 114 115 116
      </ReferencePath>
    </ItemGroup>
  </Target>
</Project>