Skip to content

Commit

Permalink
Error when targeting net5 (#1247)
Browse files Browse the repository at this point in the history
* Update help message and target that errors

* embedded targets

* message

* before targets

Co-authored-by: Manodasan Wignarajah <mawign@microsoft.com>
  • Loading branch information
j0shuams and manodasanW authored Aug 17, 2022
1 parent 9eabe30 commit fa7f556
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion nuget/Microsoft.Windows.CsWinRT.Embedded.targets
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Copyright (C) Microsoft Corporation. All rights reserved.
<ItemGroup>
<Reference Remove="WinRT.Runtime" />
<RuntimeCopyLocalItems Remove="@(RuntimeCopyLocalItems)" Condition="'%(DestinationSubPath)' == 'WinRT.Runtime.dll'"/>
<ResolvedCompileFileDefinitions Remove="@(ResolvedCompileFileDefinitions)" Condition="'%(HintPath)' == '$(CsWinRTPath)lib\net5.0\WinRT.Runtime.dll'"/>
<ResolvedCompileFileDefinitions Remove="@(ResolvedCompileFileDefinitions)" Condition="'%(HintPath)' == '$(CsWinRTPath)lib\net6.0\WinRT.Runtime.dll'"/>
</ItemGroup>

</Target>
Expand Down
4 changes: 4 additions & 0 deletions nuget/Microsoft.Windows.CsWinRT.targets
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ Copyright (C) Microsoft Corporation. All rights reserved.

<Import Project="$(MSBuildThisFileDirectory)Microsoft.Windows.CsWinRT.Embedded.targets" Condition="'$(CsWinRTEmbedded)' == 'true'"/>

<Target Name="CsWinRTNet5EOL" Condition="$([MSBuild]::GetTargetFrameworkVersion('$(TargetFramework)')) == 5" BeforeTargets="CsWinRTPrepareProjection">
<Error Text="Support for .NET 5 ended with C#/WinRT 2.0. For .NET 5 support, use C#/WinRT version 1.6.5. See https://github.com/microsoft/CsWinRT/discussions/1232" />
</Target>

<!-- Remove WinRT.Host.dll and WinRT.Host.Shim.dll references -->
<Target Name="CsWinRTRemoveHostingDllReferences" AfterTargets="ResolvePackageAssets" BeforeTargets="ResolveLockFileAnalyzers" Outputs="@(Reference)">
<PropertyGroup>
Expand Down
2 changes: 2 additions & 0 deletions src/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

<Import Condition="'$(MSBuildProjectExtension)' == '.csproj' and '$(SimulateCsWinRTNugetReference)' == 'true'" Project="..\nuget\Microsoft.Windows.CsWinRT.targets" />

<Target Name="CsWinRTNet5EOL" />

<Target Name="CsWinRTCheckDependencies" BeforeTargets="PrepareForBuild">
<Error Condition="!Exists('$(SolutionDir)TestWinRT')" Text="This solution requires the TestWinRT repo, which is missing. Please run build.cmd from a Visual Studio command prompt." />
</Target>
Expand Down
2 changes: 1 addition & 1 deletion src/cswinrt/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace cswinrt
{ "output", 0, 1, "<path>", "Location of generated projection" },
{ "include", 0, option::no_max, "<prefix>", "One or more prefixes to include in projection" },
{ "exclude", 0, option::no_max, "<prefix>", "One or more prefixes to exclude from projection" },
{ "target", 0, 1, "<net6.0|net5.0|netstandard2.0>", "Target TFM for projection. Omit for compatibility with newest TFM (net5.0)." },
{ "target", 0, 1, "<net6.0|netstandard2.0>", "Target TFM for projection. Omit for compatibility with newest TFM (net6.0)." },
{ "component", 0, 0, {}, "Generate component projection." },
{ "verbose", 0, 0, {}, "Show detailed progress information" },
{ "internal", 0, 0, {}, "Generates a private projection."},
Expand Down

0 comments on commit fa7f556

Please sign in to comment.