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

Simplify .NETFramework tfms #58558

Merged
merged 6 commits into from
Sep 10, 2021

Conversation

ViktorHofer
Copy link
Member

@ViktorHofer ViktorHofer commented Sep 2, 2021

Libraries which target .NET Framework usually have rid agnostic tfms,
i.e. net461. If the library targets netstandard2.0-windows as well,
the .NET Framework tfm must be rid specific, as rid specific
.NET Framework apps would otherwise pick the .NETStandard asset over
the .NETFramework one (based on the RID compatibility rules)

There is yet another reason that requires .NETFramework tfms to be RID
specific, which is when a project P2Ps other projects which are
rid-specific. Without the RID specific .NETFramework tfm, a compatible
.NETStandard asset would be picked instead.

NuGet doesn't support setting a TargetPlatform in the TargetFramework
alias when targeting .NETFramework or .NETStandard. Any such tfms in
dotnet/runtime are currently leveraging a hack that strips the
TargetPlatform / TargetFrameworkSuffix away during restore and packaging
(as NuGet Pack uses the project.assets.json file).

As NuGet will likely never support RID specific .NETFramework tfm
aliases, the distinction between a RID specific and a RID agnostic
.NETFramework tfm is unnecessary.

Remove all "TargetFrameworkSuffixes" / TargetPlatforms / RIDs
(whatever you would like to call them) from .NETFramework tfms and let
the packaging targets handle the cases where a RID specific asset is
required in the package.

Explictly don't set TargetsWindows to true for .NETFramework builds as
the Targets* properties are infered from the platform / suffix and
many projects make the assumption that net461
(without the "-windows" part) does mean TargetsWindows != true.

Also cleaning up the packaging.targets file and removing
the ExcludeFromPackage option which isn't needed anymore as
target frameworks aren't excluded from packages produced in
dotnet/runtime anymore.

Fixes #58495

@ViktorHofer ViktorHofer added this to the 7.0.0 milestone Sep 2, 2021
@ViktorHofer ViktorHofer requested a review from ericstj September 2, 2021 14:10
@ViktorHofer ViktorHofer self-assigned this Sep 2, 2021
@ghost
Copy link

ghost commented Sep 2, 2021

Tagging subscribers to this area: @Anipik, @safern, @ViktorHofer
See info in area-owners.md if you want to be subscribed.

Issue Details

Libraries which target .NET Framework usually have rid agnostic tfms,
i.e. net461. If the library targets netstandard2.0-windows as well,
the .NET Framework tfm must be rid specific, as rid specific
.NET Framework apps would otherwise pick the .NETStandard asset over
the .NETFramework one (based on the RID compatibility rules)

There is yet another reason that requires .NETFramework tfms to be RID
specific, which is when a project P2Ps other projects which are
rid-specific. Without the RID specific .NETFramework tfm, a compatible
.NETStandard asset would be picked instead.

NuGet doesn't support setting a TargetPlatform in the TargetFramework
alias when targeting .NETFramework or .NETStandard. Any such tfms in
dotnet/runtime are currently leveraging a hack that strips the
TargetPlatform / TargetFrameworkSuffix away during restore and packaging
(as NuGet Pack uses the project.assets.json file).

As NuGet will likely never support RID specific .NETFramework tfm
aliases, the distinction between a RID specific and a RID agnostic
.NETFramework tfm is unnecessary.

Remove all "TargetFrameworkSuffixes" / TargetPlatforms / RIDs
(whatever you would like to call them) from .NETFramework tfms and let
the packaging targets handle the cases where a RID specific asset is
required in the package.

Explictly don't set TargetsWindows to true for .NETFramework builds as
the Targets* properties are infered from the platform / suffix and
many projects make the assumption that net461
(without the "-windows" part) doesn't set TargetsWindows=true.

Also cleaning up the packaging.targets file to make this change easier.

Fixes #58495

Author: ViktorHofer
Assignees: ViktorHofer
Labels:

area-Infrastructure-libraries

Milestone: 7.0.0

@ericstj ericstj requested review from joperezr and Anipik September 2, 2021 15:29
@ViktorHofer ViktorHofer force-pushed the SimplfyNetFxConfigurations branch from 307af17 to 8f014be Compare September 2, 2021 15:37
@ViktorHofer ViktorHofer changed the title Simplfy .NETFramework tfms Simplify .NETFramework tfms Sep 2, 2021
Copy link
Member

@ericstj ericstj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Were you able to test if the package testing leg will catch if we somehow get this wrong? If it doesn't catch it then I think we should be able to make a small change to raise runtime-targets for .NETFramework. I see that NuGet does create them.

        "compile": {
          "ref/net461/Microsoft.Win32.Registry.dll": {}
        },
        "runtime": {
          "lib/net461/Microsoft.Win32.Registry.dll": {}
        },
        "runtimeTargets": {
          "runtimes/win/lib/net461/Microsoft.Win32.Registry.dll": {
            "assetType": "runtime",
            "rid": "win"
          }
        }

eng/packaging.targets Show resolved Hide resolved
eng/packaging.targets Show resolved Hide resolved
docs/coding-guidelines/libraries-packaging.md Show resolved Hide resolved
@ViktorHofer
Copy link
Member Author

Were you able to test if the package testing leg will catch if we somehow get this wrong? If it doesn't catch it then I think we should be able to make a small change to raise runtime-targets for .NETFramework. I see that NuGet does create them.

Do you have an example of what to test for?

@ericstj
Copy link
Member

ericstj commented Sep 7, 2021

Try to force a case where a package would have lib/net461 facade and a runtimes/win/lib/netstandard2.0 implementation but not runtimes/win/lib/net461. Potentially you might need to remove a portion of your change to cause this (think of it as TDD). I would hope that we'd catch this problem and point out the duplicate types in the runtimes/win/lib/netstandard2.0 + .NETFramework.

@ViktorHofer
Copy link
Member Author

ViktorHofer commented Sep 8, 2021

Try to force a case where a package would have lib/net461 facade and a runtimes/win/lib/netstandard2.0 implementation but not runtimes/win/lib/net461. Potentially you might need to remove a portion of your change to cause this (think of it as TDD). I would hope that we'd catch this problem and point out the duplicate types in the runtimes/win/lib/netstandard2.0 + .NETFramework.

Tried that with ProtectedData and neither PackageValidation nor the runtime-repo specific testPackages infrastructure catches that.

image

  Testing Microsoft.Win32.Registry.AccessControl TFM=net461
  Testing Microsoft.Win32.Registry.AccessControl TFM=net462
  Testing Microsoft.Win32.Registry.AccessControl TFM=net6.0
  Testing System.Security.Cryptography.ProtectedData TFM=net461
  Testing Microsoft.Win32.Registry.AccessControl TFM=netcoreapp3.1
  Testing Microsoft.Win32.Registry.AccessControl TFM=netstandard2.0
  Testing Microsoft.Win32.Registry.AccessControl runtime on TFM=net6.0 RIDs=none;win
  Testing closure for Microsoft.Win32.Registry.AccessControl TFM=net6.0 RID=none
  Testing Microsoft.Win32.Registry.AccessControl runtime on TFM=net462 RIDs=none
  Testing for duplicate types for Microsoft.Win32.Registry.AccessControl TFM=net462 RID=none
  Testing closure for Microsoft.Win32.Registry.AccessControl TFM=net6.0 RID=win
  Testing for duplicate types for Microsoft.Win32.Registry.AccessControl TFM=net6.0 RID=none
  Testing System.Security.Cryptography.ProtectedData TFM=net6.0
  Testing System.Security.Cryptography.ProtectedData runtime on TFM=net461 RIDs=none
  Testing for duplicate types for System.Security.Cryptography.ProtectedData TFM=net461 RID=none
  Testing for duplicate types for Microsoft.Win32.Registry.AccessControl TFM=net6.0 RID=win
  Testing Microsoft.Win32.Registry.AccessControl runtime on TFM=net461 RIDs=none
  Testing for duplicate types for Microsoft.Win32.Registry.AccessControl TFM=net461 RID=none
  Testing System.Security.Cryptography.ProtectedData TFM=netstandard2.0
  Testing System.Security.Cryptography.ProtectedData TFM=netcoreapp3.1
  Testing System.Security.Cryptography.ProtectedData TFM=net462
  Testing Microsoft.Win32.Registry.AccessControl runtime on TFM=netstandard2.0 RIDs=none
  Testing closure for Microsoft.Win32.Registry.AccessControl TFM=netstandard2.0 RID=none
  Testing for duplicate types for Microsoft.Win32.Registry.AccessControl TFM=netstandard2.0 RID=none
  Testing System.Security.Cryptography.ProtectedData runtime on TFM=net6.0 RIDs=none;win
  Testing closure for System.Security.Cryptography.ProtectedData TFM=net6.0 RID=none
  Testing closure for System.Security.Cryptography.ProtectedData TFM=net6.0 RID=win
  Testing Microsoft.Win32.Registry.AccessControl runtime on TFM=netcoreapp3.1 RIDs=none;win
  Testing closure for Microsoft.Win32.Registry.AccessControl TFM=netcoreapp3.1 RID=none
  Testing System.Security.Cryptography.ProtectedData runtime on TFM=netstandard2.0 RIDs=none
  Testing closure for System.Security.Cryptography.ProtectedData TFM=netstandard2.0 RID=none
  Testing for duplicate types for System.Security.Cryptography.ProtectedData TFM=net6.0 RID=none
  Testing for duplicate types for System.Security.Cryptography.ProtectedData TFM=netstandard2.0 RID=none
  Testing for duplicate types for System.Security.Cryptography.ProtectedData TFM=net6.0 RID=win
  Testing closure for Microsoft.Win32.Registry.AccessControl TFM=netcoreapp3.1 RID=win
  Testing for duplicate types for Microsoft.Win32.Registry.AccessControl TFM=netcoreapp3.1 RID=none
  Testing System.Security.Cryptography.ProtectedData runtime on TFM=netcoreapp3.1 RIDs=none;win
  Testing closure for System.Security.Cryptography.ProtectedData TFM=netcoreapp3.1 RID=none
  Testing for duplicate types for Microsoft.Win32.Registry.AccessControl TFM=netcoreapp3.1 RID=win
  Testing System.Security.Cryptography.ProtectedData runtime on TFM=net462 RIDs=none
  Testing for duplicate types for System.Security.Cryptography.ProtectedData TFM=net462 RID=none
  Testing closure for System.Security.Cryptography.ProtectedData TFM=netcoreapp3.1 RID=win
  Testing for duplicate types for System.Security.Cryptography.ProtectedData TFM=netcoreapp3.1 RID=none
  Testing for duplicate types for System.Security.Cryptography.ProtectedData TFM=netcoreapp3.1 RID=win

Build succeeded.

@ericstj
Copy link
Member

ericstj commented Sep 8, 2021

I think we can catch it if we turn on runtimeTargets for .NETFramework. That will give us coverage for the runtime-specific scenario. We might want to ignore any runtimeTargets that don't start with win (since we don't really care if someone who builds a .NETFramework project for RID = linux gets wrong asset).

@ericstj
Copy link
Member

ericstj commented Sep 8, 2021

Looks like setting CopyLocalRuntimeTargetAssets might do the trick.

@ViktorHofer
Copy link
Member Author

That worked quite well 👍 Thanks Eric. At some point I need to familiarize myself with the project.assets.json format...

C:\git\runtime3\artifacts\bin\testPackages\packageTest.targets(127,5): error : Duplicate type System.Security.Cryptography.DataProtectionScope in both C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Security.dll and C:\git\runtime3\artifacts\bin\testPackages\cache\system.security.cryptography.protecteddata\7.0.0-dev\runtimes\win\lib\netstandard2.0\System.Security.Cryptography.ProtectedData.dll. [C:\git\runtime3\artifacts\bin\testPackages\projects\System.Security.Cryptography.ProtectedData\project.csproj]
C:\git\runtime3\artifacts\bin\testPackages\packageTest.targets(127,5): error : Duplicate type System.Security.Cryptography.ProtectedData in both C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Security.dll and C:\git\runtime3\artifacts\bin\testPackages\cache\system.security.cryptography.protecteddata\7.0.0-dev\runtimes\win\lib\netstandard2.0\System.Security.Cryptography.ProtectedData.dll. [C:\git\runtime3\artifacts\bin\testPackages\projects\System.Security.Cryptography.ProtectedData\project.csproj]
C:\git\runtime3\artifacts\bin\testPackages\packageTest.targets(127,5): error : Duplicate type System.Security.Cryptography.DataProtectionScope in both C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.2\System.Security.dll and C:\git\runtime3\artifacts\bin\testPackages\cache\system.security.cryptography.protecteddata\7.0.0-dev\runtimes\win\lib\netstandard2.0\System.Security.Cryptography.ProtectedData.dll. [C:\git\runtime3\artifacts\bin\testPackages\projects\System.Security.Cryptography.ProtectedData\project.csproj]
C:\git\runtime3\artifacts\bin\testPackages\packageTest.targets(127,5): error : Duplicate type System.Security.Cryptography.ProtectedData in both C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.2\System.Security.dll and C:\git\runtime3\artifacts\bin\testPackages\cache\system.security.cryptography.protecteddata\7.0.0-dev\runtimes\win\lib\netstandard2.0\System.Security.Cryptography.ProtectedData.dll. [C:\git\runtime3\artifacts\bin\testPackages\projects\System.Security.Cryptography.ProtectedData\project.csproj]

Libraries which target .NET Framework usually have rid agnostic tfms,
i.e. net461. If the library targets netstandard2.0-windows as well,
the .NET Framework tfm must be rid specific, as rid specific
.NET Framework apps would otherwise pick the .NETStandard asset over
the .NETFramework one (based on the RID compatibility rules)

There is yet another reason that requires .NETFramework tfms to be RID
specific, which is when a project P2Ps other projects which are
rid-specific. Without the RID specific .NETFramework tfm, a compatible
.NETStandard asset would be picked instead.

NuGet doesn't support setting a TargetPlatform in the TargetFramework
alias when targeting .NETFramework or .NETStandard. Any such tfms in
dotnet/runtime are currently leveraging a hack that strips the
TargetPlatform / TargetFrameworkSuffix away during restore and packaging
(as NuGet Pack uses the project.assets.json file).

As NuGet will likely never support RID specific .NETFramework tfm
aliases, the distinction between a RID specific and a RID agnostic
.NETFramework tfm is unnecessary.

Remove all "TargetFrameworkSuffixes" / TargetPlatforms / RIDs
(whatever you would like to call them) from .NETFramework tfms and let
the packaging targets handle the cases where a RID specific asset is
required in the package.

Explictly don't set TargetsWindows to true for .NETFramework builds as
the Targets* properties are infered from the platform / suffix and
many projects make the assumption that net461
(without the "-windows" part) doesn't set TargetsWindows=true.

Fixes dotnet#58495
@ViktorHofer ViktorHofer force-pushed the SimplfyNetFxConfigurations branch from 8f014be to 54e0de2 Compare September 8, 2021 20:27
ViktorHofer added a commit to dotnet/arcade that referenced this pull request Sep 9, 2021
With dotnet/runtime#58558, .NETFramework tfms which include a RID (i.e. net461-windows) aren't used and supported in dotnet/runtime anymore. Removing the support from the TargetFramework.Sdk as .NETFramework tfms with a RID aren't supported by NuGet anyways and throw.
@ViktorHofer
Copy link
Member Author

D:\workspace\_work\1\s\artifacts\bin\testPackages\packageTest.targets(127,5): error : Duplicate type System.IO.Ports.Handshake in both C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.2\System.dll and D:\workspace\_work\1\s\artifacts\bin\testPackages\cache\system.io.ports\7.0.0-ci\runtimes\unix\lib\netstandard2.0\System.IO.Ports.dll. [D:\workspace\_work\1\s\artifacts\bin\testPackages\projects\System.IO.Ports\project.csproj]
D:\workspace\_work\1\s\artifacts\bin\testPackages\packageTest.targets(127,5): error : Duplicate type System.IO.Ports.Parity in both C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.2\System.dll and D:\workspace\_work\1\s\artifacts\bin\testPackages\cache\system.io.ports\7.0.0-ci\runtimes\unix\lib\netstandard2.0\System.IO.Ports.dll. [D:\workspace\_work\1\s\artifacts\bin\testPackages\projects\System.IO.Ports\project.csproj]
D:\workspace\_work\1\s\artifacts\bin\testPackages\packageTest.targets(127,5): error : Duplicate type System.IO.Ports.SerialData in both C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.2\System.dll and D:\workspace\_work\1\s\artifacts\bin\testPackages\cache\system.io.ports\7.0.0-ci\runtimes\unix\lib\netstandard2.0\System.IO.Ports.dll. [D:\workspace\_work\1\s\artifacts\bin\testPackages\projects\System.IO.Ports\project.csproj]
D:\workspace\_work\1\s\artifacts\bin\testPackages\packageTest.targets(127,5): error : Duplicate type System.IO.Ports.SerialDataReceivedEventArgs in both C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.2\System.dll and D:\workspace\_work\1\s\artifacts\bin\testPackages\cache\system.io.ports\7.0.0-ci\runtimes\unix\lib\netstandard2.0\System.IO.Ports.dll. [D:\workspace\_work\1\s\artifacts\bin\testPackages\projects\System.IO.Ports\project.csproj]
D:\workspace\_work\1\s\artifacts\bin\testPackages\packageTest.targets(127,5): error : Duplicate type System.IO.Ports.SerialDataReceivedEventHandler in both C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.2\System.dll and D:\workspace\_work\1\s\artifacts\bin\testPackages\cache\system.io.ports\7.0.0-ci\runtimes\unix\lib\netstandard2.0\System.IO.Ports.dll. [D:\workspace\_work\1\s\artifacts\bin\testPackages\projects\System.IO.Ports\project.csproj]
D:\workspace\_work\1\s\artifacts\bin\testPackages\packageTest.targets(127,5): error : Duplicate type System.IO.Ports.SerialError in both C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.2\System.dll and D:\workspace\_work\1\s\artifacts\bin\testPackages\cache\system.io.ports\7.0.0-ci\runtimes\unix\lib\netstandard2.0\System.IO.Ports.dll. [D:\workspace\_work\1\s\artifacts\bin\testPackages\projects\System.IO.Ports\project.csproj]
D:\workspace\_work\1\s\artifacts\bin\testPackages\packageTest.targets(127,5): error : Duplicate type System.IO.Ports.SerialErrorReceivedEventArgs in both C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.2\System.dll and D:\workspace\_work\1\s\artifacts\bin\testPackages\cache\system.io.ports\7.0.0-ci\runtimes\unix\lib\netstandard2.0\System.IO.Ports.dll. [D:\workspace\_work\1\s\artifacts\bin\testPackages\projects\System.IO.Ports\project.csproj]
D:\workspace\_work\1\s\artifacts\bin\testPackages\packageTest.targets(127,5): error : Duplicate type System.IO.Ports.SerialErrorReceivedEventHandler in both C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.2\System.dll and D:\workspace\_work\1\s\artifacts\bin\testPackages\cache\system.io.ports\7.0.0-ci\runtimes\unix\lib\netstandard2.0\System.IO.Ports.dll. [D:\workspace\_work\1\s\artifacts\bin\testPackages\projects\System.IO.Ports\project.csproj]
D:\workspace\_work\1\s\artifacts\bin\testPackages\packageTest.targets(127,5): error : Duplicate type System.IO.Ports.SerialPinChange in both C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.2\System.dll and D:\workspace\_work\1\s\artifacts\bin\testPackages\cache\system.io.ports\7.0.0-ci\runtimes\unix\lib\netstandard2.0\System.IO.Ports.dll. [D:\workspace\_work\1\s\artifacts\bin\testPackages\projects\System.IO.Ports\project.csproj]
D:\workspace\_work\1\s\artifacts\bin\testPackages\packageTest.targets(127,5): error : Duplicate type System.IO.Ports.SerialPinChangedEventArgs in both C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.2\System.dll and D:\workspace\_work\1\s\artifacts\bin\testPackages\cache\system.io.ports\7.0.0-ci\runtimes\unix\lib\netstandard2.0\System.IO.Ports.dll. [D:\workspace\_work\1\s\artifacts\bin\testPackages\projects\System.IO.Ports\project.csproj]
D:\workspace\_work\1\s\artifacts\bin\testPackages\packageTest.targets(127,5): error : Duplicate type System.IO.Ports.SerialPinChangedEventHandler in both C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.2\System.dll and D:\workspace\_work\1\s\artifacts\bin\testPackages\cache\system.io.ports\7.0.0-ci\runtimes\unix\lib\netstandard2.0\System.IO.Ports.dll. [D:\workspace\_work\1\s\artifacts\bin\testPackages\projects\System.IO.Ports\project.csproj]
D:\workspace\_work\1\s\artifacts\bin\testPackages\packageTest.targets(127,5): error : Duplicate type System.IO.Ports.SerialPort in both C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.2\System.dll and D:\workspace\_work\1\s\artifacts\bin\testPackages\cache\system.io.ports\7.0.0-ci\runtimes\unix\lib\netstandard2.0\System.IO.Ports.dll. [D:\workspace\_work\1\s\artifacts\bin\testPackages\projects\System.IO.Ports\project.csproj]
D:\workspace\_work\1\s\artifacts\bin\testPackages\packageTest.targets(127,5): error : Duplicate type System.IO.Ports.StopBits in both C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.2\System.dll and D:\workspace\_work\1\s\artifacts\bin\testPackages\cache\system.io.ports\7.0.0-ci\runtimes\unix\lib\netstandard2.0\System.IO.Ports.dll. [D:\workspace\_work\1\s\artifacts\bin\testPackages\projects\System.IO.Ports\project.csproj]

@ericstj @Anipik any idea why the Unix asset is considered compatible for the .NETFramework runtime targets?

@ericstj
Copy link
Member

ericstj commented Sep 9, 2021

@ericstj @Anipik any idea why the Unix asset is considered compatible for the .NETFramework runtime targets?

This is what I said you'd want to look out for above:

We might want to ignore any runtimeTargets that don't start with win (since we don't really care if someone who builds a .NETFramework project for RID = linux gets wrong asset).

The toolchain has no knowledge of what RID's are "valid" for a particular framework, it just provides runtimeTargets in case they might be used. On .NETCore it's the host's decision to decide if it happens to use one of those (based on the RID fallback graph it has for the particular runtime it's running on). Package testing is trying to make sure that any asset that "might" apply for any RID meets our test criteria. Since it's not a scenario to restore .NETFramework for non-Windows RIDs I don't think we need to test them (nor force our packages to add non-windows-RID-specific netframework assets).

<!-- Don't verify RID specific libs that aren't compatible on .NETFramework, i.e. Unix. -->
<RuntimeLibToTest Remove="@(RuntimeLibToTest)" Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework' and
'%(RuntimeLibToTest.RuntimeIdentifier)' != '' and
'%(RuntimeLibToTest.RuntimeIdentifier)' != 'win'" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

win- wouldn't catch "win" itself so I guess checking (eq "win" or startswith("win-")) is necessary:

image

@joperezr
Copy link
Member

joperezr commented Sep 9, 2021

Hven't fully looked at the PR yet (going over it now) but looks like most of the discussion about regression testing above was in order to catch cases where our logic to automatically add the rid-specific asset failed. That said, do we also have some sort of coverage for cases where P2Ps of a net461 project would pick the netstandard2.0-windows over the net461 ridless asset? Or is it that this will now never be an issue because we won't have any net461-win configurations anymore so all P2Ps will always prefer other net461 configs over netstandard2.0-win configs?

@ViktorHofer
Copy link
Member Author

Or is it that this will now never be an issue because we won't have any net461-win configurations anymore so all P2Ps will always prefer other net461 configs over netstandard2.0-win configs?

Correct. With .NETFramework RID agnostic project configurations only, a compatible (RID specific) netstandard2.0 configuration can't win over a compatible .NETFramework configuration.

@joperezr
Copy link
Member

joperezr commented Sep 9, 2021

And do we have regression testing to ensure that nobody will add a netfx-win config by mistake in the future? As that would bring the P2P problem back.

@ViktorHofer
Copy link
Member Author

And do we have regression testing to ensure that nobody will add a netfx-win config by mistake in the future? As that would bring the P2P problem back.

#58558 (comment)

@joperezr
Copy link
Member

joperezr commented Sep 9, 2021

Final general comment before actually looking into the PR 😄: Seems like in the PR description you are not making any special note about removing the support for ExcludeFromPackage which we are now doing here. Might be useful to add a note in there explaining why we are doing it for future reference.

@@ -21,17 +21,15 @@ System.Security.AccessControl.SemaphoreSecurity</PackageDescription>
<IsPartialFacadeAssembly Condition="$([MSBuild]::GetTargetFrameworkIdentifier('$(TargetFramework)')) == '.NETFramework'">true</IsPartialFacadeAssembly>
<GeneratePlatformNotSupportedAssemblyMessage Condition="'$(IsPartialFacadeAssembly)' != 'true' and '$(TargetsWindows)' != 'true'">SR.PlatformNotSupported_AccessControl</GeneratePlatformNotSupportedAssemblyMessage>
</PropertyGroup>
<ItemGroup Condition="'$(TargetsWindows)' == 'true'">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is technically a change as we were compiling this file before on the netfx asset. That said it was obviously a mistake so it was a good catch to find here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@joperezr joperezr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good to me, thanks for fixing this @ViktorHofer I really like the simplified configurations much better. Might be good just to super double check that your changes didn't actually modified the resulting packages by diffing them before and after your change.

@ViktorHofer
Copy link
Member Author

Test failures are #58927
Hang is #58549

@ViktorHofer ViktorHofer merged commit 331823f into dotnet:main Sep 10, 2021
@ViktorHofer ViktorHofer deleted the SimplfyNetFxConfigurations branch September 10, 2021 07:50
ViktorHofer added a commit to dotnet/arcade that referenced this pull request Sep 10, 2021
With dotnet/runtime#58558, .NETFramework tfms which include a RID (i.e. net461-windows) aren't used and supported in dotnet/runtime anymore. Removing the support from the TargetFramework.Sdk as .NETFramework tfms with a RID aren't supported by NuGet anyways and throw.
ViktorHofer added a commit to dotnet/arcade that referenced this pull request Sep 10, 2021
* Don't strip .NETFramework tfms

With dotnet/runtime#58558, .NETFramework tfms which include a RID (i.e. net461-windows) aren't used and supported in dotnet/runtime anymore. Removing the support from the TargetFramework.Sdk as .NETFramework tfms with a RID aren't supported by NuGet anyways and throw.

* Update Microsoft.DotNet.Build.Tasks.TargetFramework.Sdk.targets
@ghost ghost locked as resolved and limited conversation to collaborators Oct 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Simplify .NETFramework tfms by avoiding the "-windows" RID
3 participants