winget-cli

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

ReferenceEmbeddedCsWinRTProject.targets (3250B)


      1 <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
      2   <PropertyGroup>
      3     <IncludeWindowsSDKRefFrameworkReferences>false</IncludeWindowsSDKRefFrameworkReferences>
      4   </PropertyGroup>
      5 
      6   <!-- Prevent .winmd files from being referenced transitively. -->
      7   <!-- Adapted from https://github.com/microsoft/CsWinRT/blob/master/nuget/Microsoft.Windows.CsWinRT.targets -->
      8   <Target Name="WinGetRemoveWinMDReferences" BeforeTargets="BeforeCompile" AfterTargets="ResolveReferences">
      9     <ItemGroup>
     10       <!--Move winmd references into private item group to prevent subsequent winmd reference errors-->
     11       <WinGetRemovedReferences Include="@(ReferencePath)" Condition="'%(ReferencePath.Extension)' == '.winmd'" />
     12 
     13       <!--Prevent NETSDK1130 errors from winmd references-->
     14       <ReferencePath Remove="@(ReferencePath)" Condition="'%(ReferencePath.Extension)' == '.winmd'" />
     15       <ReferencePathWithRefAssemblies Remove="@(WinGetRemovedReferences)"
     16         Condition="'%(WinGetRemovedReferences.Filename)%(WinGetRemovedReferences.Extension)' == '%(ReferencePathWithRefAssemblies.Filename)%(ReferencePathWithRefAssemblies.Extension)'" />
     17       <!--Do not publish projection source winmd files, but do include implementation dlls -->
     18       <ReferenceCopyLocalPaths Remove="@(WinGetRemovedReferences)" />
     19       <ReferenceCopyLocalPaths Include="@(WinGetRemovedReferences->'%(RootDir)%(Directory)%(DestinationSubDirectory)%(Implementation)')"
     20                                Condition="'%(WinGetRemovedReferences.Implementation)' != '' AND '$([System.IO.Path]::GetExtension(%(WinGetRemovedReferences.Implementation)))' == '.dll' AND Exists('%(WinGetRemovedReferences.RootDir)%(WinGetRemovedReferences.Directory)%(WinGetRemovedReferences.DestinationSubDirectory)%(WinGetRemovedReferences.Implementation)')" />
     21       <!--Remove winmd references from deps.json to prevent CLR failing unit test execution-->
     22       <ReferenceDependencyPaths Remove="@(ReferenceDependencyPaths)" Condition="%(ReferenceDependencyPaths.Extension) == '.winmd'"/>
     23     </ItemGroup>
     24   </Target>
     25 
     26   <!-- Prevent WinRT.Runtime from being referenced. -->
     27   <!-- Adapted from https://github.com/microsoft/CsWinRT/blob/master/nuget/Microsoft.Windows.CsWinRT.Embedded.targets -->
     28   <Target Name="WinGetRemoveWinRTRuntimeReference" 
     29           Inputs="@(RuntimeCopyLocalItems)" 
     30           AfterTargets="ResolvePackageAssets" 
     31           Outputs="@(RuntimeCopyLocalItems)">
     32 
     33     <ItemGroup>
     34       <Reference Remove="WinRT.Runtime" /> 
     35       <RuntimeCopyLocalItems Remove="@(RuntimeCopyLocalItems)" Condition="'%(DestinationSubPath)' == 'WinRT.Runtime.dll'"/>
     36       <ResolvedCompileFileDefinitions Remove="@(ResolvedCompileFileDefinitions)" Condition="'$([System.IO.Path]::GetFileName(%(HintPath)))' == 'WinRT.Runtime.dll'"/>
     37     </ItemGroup>
     38   </Target>
     39 
     40   <!-- Remove any items from ReferenceCopyLocalPaths that have CopyLocal set to false. -->
     41   <Target Name="WinGetRemoveCopyLocalReferencesAsNeeded" AfterTargets="WinGetRemoveWinMDReferences">
     42     <ItemGroup>
     43       <ReferenceCopyLocalPaths Remove="@(ReferenceCopyLocalPaths)" Condition="%(ReferenceCopyLocalPaths.CopyLocal) == 'false'" />
     44     </ItemGroup>
     45   </Target>
     46 </Project>