Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Update the S.T.E.W configurations to explicitly target a versioned TFM (nc3.0).#42069

Merged
safern merged 6 commits intodotnet:masterfrom
ahsonkhan:FixPackaging
Oct 25, 2019
Merged

Update the S.T.E.W configurations to explicitly target a versioned TFM (nc3.0).#42069
safern merged 6 commits intodotnet:masterfrom
ahsonkhan:FixPackaging

Conversation

@ahsonkhan
Copy link

@ahsonkhan ahsonkhan commented Oct 23, 2019

The assets within the package on 3.0 were:
ns1.0, 2.0, 2.1

With this change (in master) we are adding a new asset:
ns1.0, 2.0, 2.1, nc3.0

Without this change, the new asset was targeting nc5.0 which isn't what we want.

Addresses #41933 (comment)

cc @ericstj, @ViktorHofer, @Anipik

<RootNamespace>System.Text.Encodings.Web</RootNamespace>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Configurations>netcoreapp-Debug;netcoreapp-Release;netstandard-Debug;netstandard-Release;netstandard2.1-Debug;netstandard2.1-Release</Configurations>
<Configurations>netcoreapp3.0-Debug;netcoreapp3.0-Release;netstandard-Debug;netstandard-Release;netstandard2.1-Debug;netstandard2.1-Release</Configurations>
Copy link
Author

@ahsonkhan ahsonkhan Oct 23, 2019

Choose a reason for hiding this comment

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

Continuing to use TargetsNetCoreApp within item group conditions is fine, even with this change, correct?

<TargetsNetCoreApp Condition="$(TargetFramework.StartsWith('netcoreapp'))">true</TargetsNetCoreApp>

What about using the SDK constant in source for if/defs? Should these be changed to TFM specific (i.e. NETCOREAPP3_0)? I don't see any other use of that in the repo, but maybe this is the first instance. I see older TFMS though.

#if NETCOREAPP
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.X86;
#endif

Copy link
Member

Choose a reason for hiding this comment

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

Yes using TargetsNetCoreApp is fine. On the defines: in master I believe we use the SDK pattern where netcoreapp means any version, so these should be fine. Double check the IL to be sure (or test for the difference).

Copy link
Author

@ahsonkhan ahsonkhan Oct 23, 2019

Choose a reason for hiding this comment

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

Double check the IL to be sure (or test for the difference).

Yep, that's what I am doing to verify. I could instead use a custom constant, like we do in S.T.Json (that has the added benefit of being in sync with what we are doing in the release/3.1 for S.T.E.Web).

<DefineConstants Condition="'$(TargetsNETStandard)' != 'true' AND '$(TargetsNetFx)' != 'true'">$(DefineConstants);BUILDING_INBOX_LIBRARY</DefineConstants>

Edit: Yep, works as expected.

<PropertyGroup>
<BuildConfigurations>
netcoreapp;
netcoreapp3.0;
Copy link
Author

@ahsonkhan ahsonkhan Oct 24, 2019

Choose a reason for hiding this comment

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

Some of the references that S.T.E.W depends on don't have a config for netcoreapp3.0.
System.Diagnostics.Debug
System.Memory
System.Runtime
etc.

Should we also add the versioned TFM configs to all those (along side the version-less ones) or do we need to add package configurations here, instead?

netcoreapp-Unix;
netcoreapp-Windows_NT;

netcoreapp-Windows_NT;
netcoreapp-Unix;

That's causing the CI failures:

##[error].dotnet\sdk\3.0.100\Microsoft.Common.CurrentVersion.targets(2106,5): error MSB3245: Could not resolve this reference. Could not locate the assembly "System.Runtime". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.

Copy link
Author

Choose a reason for hiding this comment

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

build -allconfigurations succeeds but targeting individual frameworks (particularly the default - netcoreapp) fails.

Copy link
Member

Choose a reason for hiding this comment

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

This library is inbox as well so you will need a version-less build configuration but you will need to exclude it from the packages configuration so that it targets the latest.

So you do something like:

<PackageConfigurations>
  netcoreapp3.0;
  netstandard2.1;
  netstandard;
</PackageConfigurations>
<BuildConfigurations>
  $(PackageConfigurations);
  netcoreapp;
</BuildConfigurations>

Copy link
Author

@ahsonkhan ahsonkhan Oct 24, 2019

Choose a reason for hiding this comment

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

So you do something like

Thanks for the suggestion, @safern. That's precisely what I tried next, following precedence of other similar packages like Threading.Channels:

<PropertyGroup>
<PackageConfigurations>
netstandard1.3;
netstandard;
netcoreapp3.0;
</PackageConfigurations>
<BuildConfigurations>
$(PackageConfigurations);
netcoreapp;
</BuildConfigurations>
</PropertyGroup>

The netcoreapp3.0 package config still causes the failure though. I don't know if its because of contention caused by netstandard2.1 and netcoreapp3.0.

Let me retry that to verify.

Copy link
Author

Choose a reason for hiding this comment

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

Awesome, that worked! I wasn't updating the Configurations property in the csproj locally to include netcoreapp which is why I was seeing the failure earlier.

using System.Text.Unicode;

#if NETCOREAPP
#if BUILDING_INBOX_LIBRARY
Copy link
Member

Choose a reason for hiding this comment

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

You could do
#if !NETSTANDARD
...
#endif

And then that means anything but any version of netstandard.

Copy link
Author

Choose a reason for hiding this comment

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

Any particular reason why one is considered better than the other? #if NETCOREAPP, vs #if !NETSTANDARD, vs #if CUSTOM_CONSTANT?

Would using constants like NETSTANDARD work in release/3.1?

Copy link
Member

Choose a reason for hiding this comment

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

BUILDING_INBOX_LIBRARY is incorrect. You want this for the package build of Netcoreapp. I would recommend #if netcoreapp if that works in both master and release. I know that works in master: versionless define indicates any, as it does with the SDK. I think we still had the differing behavior in release, so a dedicated define may be appropriate. How about USE_INTRINSICS or something like that in release?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, the SDK constants do work in the release/3.x branches as well.

Copy link
Author

Choose a reason for hiding this comment

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

I would recommend #if netcoreapp if that works in both master and release.

Any difference between lower-case and upper-case? I left it as upper-case since that's what is being used across the repo.

Copy link
Member

Choose a reason for hiding this comment

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

Lower-case is what we used to define but we removed that some weeks ago, upper-case are the ones the SDK define based on the TFM.

@ahsonkhan
Copy link
Author

The change is ready for review. Let me know if anything else needs to be addressed.

@safern safern merged commit 0954a97 into dotnet:master Oct 25, 2019
@ahsonkhan ahsonkhan deleted the FixPackaging branch October 25, 2019 03:33
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
…M (nc3.0). (dotnet/corefx#42069)

* Update the S.T.E.W configurations to explicitly target a versioned TFM
(nc3.0).

* Use custom defined constant like S.T.Json - Building_Inbox_Library

* Update config.props to use package config and leave netcoreapp as a build config

* Add back netcoreapp specific config to the src csproj

* Revert "Use custom defined constant like S.T.Json - Building_Inbox_Library"

This reverts commit dotnet/corefx@8648cf6.

* Remove extra new line.


Commit migrated from dotnet/corefx@0954a97
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.

4 participants