Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when targeting net5 #1247

Merged
merged 5 commits into from
Aug 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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