Skip to content
This repository has been archived by the owner on Sep 13, 2022. It is now read-only.

Bump AssemblyVersion for nestandard.dll to 2.1.0.0 #1047

Merged
merged 17 commits into from Jan 16, 2019

Conversation

wtgodbe
Copy link
Member

@wtgodbe wtgodbe commented Jan 7, 2019

@wtgodbe wtgodbe requested review from a team as code owners January 7, 2019 19:06
@terrajobst terrajobst requested review from ericstj and removed request for a team January 7, 2019 19:16
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<OutputType>Library</OutputType>
<TargetFramework>netstandard2.0</TargetFramework>
Copy link
Member

Choose a reason for hiding this comment

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

Should this be netstandard2.1?

Copy link
Member

Choose a reason for hiding this comment

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

You may also want to look into here:

<NETStandardVersion>netstandard2.0</NETStandardVersion>
As well as what you want the behavior to be when that package is installed in older netstandard versions. Previously it tried to support the older TFMs but that might not be so scalable now that the package contains the binaries. It also may not be a requirement anymore since we don't persist the package as a dependency. Whatever you decide would need to be coordinated with the SDK folks.

@wtgodbe
Copy link
Member Author

wtgodbe commented Jan 7, 2019

@livarcocc @dsplaisted will the SDK have any issues with us bumping the Package's NetStandardVersion to 2.1, as well as the TargetFramework? Given Eric's comment, I'm feeling that that's the direction we'd want to go in for Standard.

@dsplaisted
Copy link
Member

@wtgodbe I don't know how the NetStandardVersion affects the SDK. Regardless, we are going to want to switch to using a targeting pack instead of a normal NuGet package reference. So I think you can go forward with these changes, and then there will be some back and forth between the SDK and .NET Standard to get a working targeting pack for .NET Standard 2.1.

@wtgodbe
Copy link
Member Author

wtgodbe commented Jan 7, 2019

F:\vsagent\73\s.dotnet\sdk\2.1.401\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(150,5): error NETSDK1045: The current .NET SDK does not support targeting .NET Standard 2.1. Either target .NET Standard 2.0 or lower, or use a version of the .NET SDK that supports .NET Standard 2.1. [F:\vsagent\73\s\src\netstandard\ref\netstandard.csproj]

Looks like we're hitting https://github.com/dotnet/sdk/blob/7b0fe5695ba8d8efe57cb1ae7ff95a87c194e46a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.TargetFrameworkInference.targets#L155-L162. I'm not sure how we're setting NETStandardMaximumVersion, as it appears to default to BundledNETStandardTargetFrameworkVersion, which I can't find anywhere else in the repo. @dsplaisted any idea what needs to be done there?

@wtgodbe
Copy link
Member Author

wtgodbe commented Jan 7, 2019

F:\vsagent\73\s.dotnet\sdk\2.1.401\Microsoft.Common.CurrentVersion.targets(1657,5): error : Project '....\netstandard\ref\netstandard.csproj' targets 'netstandard2.1'. It cannot be referenced by a project that targets '.NETFramework,Version=v4.6.1'. [F:\vsagent\73\s\src\platforms\extensions\System.CodeDom.csproj]

@dsplaisted
Copy link
Member

@wtgodbe You should be able to set NETStandardMaximumVersion in your project or in a .props file.

As far as the CodeDom error, that seems valid. .NET 4.6.1 won't support .NET Standard 2.1, so that reference isn't valid. I don't know the details of how your repo works, it seems like that project probably shouldn't have a P2P reference to the NETStandard project.

@wtgodbe
Copy link
Member Author

wtgodbe commented Jan 7, 2019

Looks like the old NETStandardMaximumVersion was defined in Microsoft.NETCoreSdk.BundledVersions.props, but I'm not sure where that file lives - @livarcocc @ericstj do you know? For now I can probably get away with defining it in Standard, but if we're moving to 2.0 then it'd probably be a good idea to update that file as well.

@dsplaisted
Copy link
Member

@wtgodbe You don't want to update it in the bundled versions file. You have a chicken and egg problem, you are using an SDK that doesn't support targeting .NET Standard 2.1 in order to build the .NET Standard 2.1 reference assemblies. So you should override the maximum .NET Standard version property just in your repo.

@wtgodbe
Copy link
Member Author

wtgodbe commented Jan 7, 2019

I've fixed the NETStandardMaximumVersion issue, but I'm still unsure what the best fix is for the errors in the .NET4.6.1 projects

F:\vsagent\73\s.dotnet\sdk\2.1.401\Microsoft.Common.CurrentVersion.targets(1657,5): error : Project '....\netstandard\ref\netstandard.csproj' targets 'netstandard2.1'. It cannot be referenced by a project that targets '.NETFramework,Version=v4.6.1'. [F:\vsagent\73\s\src\platforms\extensions\System.CodeDom.csproj]

https://github.com/dotnet/standard/blob/master/src/netstandard/pkg/shims/netfx/System.csproj#L10

https://github.com/dotnet/standard/blob/master/src/platforms/extensions/System.CodeDom.csproj#L9

Should I just remove the references to these projects from netfx proj's (like System.csproj)? I'm not confident that that's the right path, since there must be a good reason those specific projects were referenced in the first place. @ericstj @terrajobst any idea of what the original reasoning was here?

@ericstj
Copy link
Member

ericstj commented Jan 8, 2019

Looks to me like those projects are responsible for representing extensions built in other repos for the purposes of dangling type-forwards out of netfx shims. Per our discussion, I think we should just try to make those target netstandard2.1 if possible. If not you can probably use AssetTargetFallBack to make it work.

@wtgodbe
Copy link
Member Author

wtgodbe commented Jan 9, 2019

Everything should build successfully with my latest commit (build is good & System.dll appears the same on my box). @ericstj does everything look ship-shape?

@ericstj
Copy link
Member

ericstj commented Jan 10, 2019

We still need to answer the question of "what should this package support".

With this change, the package supports:
[NETStandard1.0,NETStandard1.6] and [NETStandard2.0]. It will install on NETStandard2.0 but will provide the NS1.6 dependencies.

If we want it to support netstandard2.0 then we'll need to harvest those assets and put them in the package. Alternatively we could drop support for the old TFMs with the expectation that the SDK will multiplex based on the TFM (and folks who have a manual package reference will never click the "Upgrade" button).

I really want the SDK folks and @terrajobst to weigh in on this.

@wtgodbe
Copy link
Member Author

wtgodbe commented Jan 10, 2019

For now, the least-breaking way to fix this may be to harvest all of the assets that used to live in netstandard.library.nupkg\build\netstandard2.0\ref, and make sure those assets wind up in that location for the 2.1 package - this probably means restoring the newest 2.0 version of the package & pulling out what's in netstandard2.0\ref.

@dsplaisted
Copy link
Member

dsplaisted commented Jan 11, 2019

@ericstj We are planning to use a targeting pack for .NET Standard 2.1. So probably we don't need to even publish a 2.1 version of NETStandard.Library to NuGet.org in the end.

In the interim until we have a targeting pack, we will probably continue to use a package similar to what currently exists. But it is fine for you to drop support for all previous versions of .NET Standard from the NuGet package, if that makes it easier for you.

See also #1051

@ericstj
Copy link
Member

ericstj commented Jan 14, 2019

@dsplaisted thanks,
we reached a similar conclusion on Thursday. We didn't want to back up the 2.1 support behind the new ref-packs/installers so we opted to do this temporary throw-away work until that was ready.

@ViktorHofer
Copy link
Member

ViktorHofer commented Jan 14, 2019

@wtgodbe please do me a favor and let's not merge this before #1040 as we probably need a few more minor updates afterwards.

@wtgodbe
Copy link
Member Author

wtgodbe commented Jan 15, 2019

@ViktorHofer we still use all of those things for APICompat, so at the least we want to continue building them. The netfx/netstandard shims are what wind up in the NetStandard.Library package.

@wtgodbe
Copy link
Member Author

wtgodbe commented Jan 15, 2019

So to be clear, we want to change instances of <TargetFramework>netstandard2.1</TargetFramework> to <TargetFramework>netstandard2.0</TargetFramework>, and we want to harvest the assets from a LKG netstandard2.0 version of NetStandard.Library, and place them in the .nupkg in the build folder next to netstandard2.1 in a folder named netstandard2.0 ?

@ericstj
Copy link
Member

ericstj commented Jan 15, 2019

I think @ViktorHofer already took care of the targetframework issue, so we just need to add the 2.0 stuff to the package.

@wtgodbe
Copy link
Member Author

wtgodbe commented Jan 15, 2019

This should be good to go now, @ericstj @ViktorHofer could you take a final look? It's now producing a package with both the netstandard2.0 and netstandard2.1 assets.

eng/Versions.props Outdated Show resolved Hide resolved
eng/Tools.props Outdated
@@ -11,6 +11,9 @@

<!-- Need to keep in sync with CodeAnalysis.targets file. -->
<AnalyzerPropsFile>$(ArtifactsToolsetDir)Common\Tools.Analyzers.props</AnalyzerPropsFile>

<!-- Restore specific version of NetStandard.library -->
<NetStandardImplicitPackageVersion>$(NetStandardLibraryPackageVersion)</NetStandardImplicitPackageVersion>
Copy link
Member

@ericstj ericstj Jan 15, 2019

Choose a reason for hiding this comment

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

Did you need to set this? I would have expected that we would have disabled all the implicit package references in this repository (so it doesn't end up referencing what we are actually building).

Copy link
Member Author

Choose a reason for hiding this comment

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

The SDK packages all implicitly reference NetStandard.Library/Microsoft.NETCore.App, if I don't set this we'll restore the default version & I won't have the path to find that package in my package cache. If I set it here, this project will restore the version that I want so I know where to find it.

Copy link
Member

Choose a reason for hiding this comment

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

Did you consider DisableImplicitFrameworkReferences?

Copy link
Member

Choose a reason for hiding this comment

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

Actually I see we already use that in some projects.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, but I figured it was easier to use the implicit reference & just give it a specific version to restore, rather than disabling the reference to NetStandard.Library then adding a manual reference to it.

Copy link
Member

@ericstj ericstj Jan 15, 2019

Choose a reason for hiding this comment

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

I see, are you sure we'll restore one of those projects that references it? The other places where we're working around missing assets file make me think we may not be. If that's the case maybe we can just add an explicit reference somewhere that we're sure will be restored.

</PropertyGroup>

<!-- Disable code paths that require project.assets.json files to be present or to be computed. -->
Copy link
Member

Choose a reason for hiding this comment

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

Did you need these? They all look netcoreapp specific, I wouldn't expect them to be causing a problem for netstandard build.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes to disable the Target that tries to resolve stuff from project.assets.json, without it I get the following error:

E:\code\standard.dotnet\sdk\2.1.401\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(129,5): error NETSDK1004: Assets file 'E:\code\standard\artifacts\obj\System.CodeDom\project.assets.json' not found. Run a NuGet package restore to generate this file. [E:\code\standard\src\platforms\extensions\System.CodeDom.csproj]

Copy link
Member

Choose a reason for hiding this comment

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

I see, that's annoying. It looks like SDK does indeed try to do this for netstandard projects. What changed that caused that to start breaking?

Copy link
Member

Choose a reason for hiding this comment

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

I guess just the retargeting to ns2.1.

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

Choose a reason for hiding this comment

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

Please consider a followup PR to centralize these properties.

Copy link
Member

Choose a reason for hiding this comment

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

Lol. One of my follow-up PRs would have been to bring back project restore so that we don't need these hacks.

Copy link
Member

Choose a reason for hiding this comment

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

Even better 👍

@wtgodbe
Copy link
Member Author

wtgodbe commented Jan 15, 2019

@ericstj I updated this so we explicitly restore NETStandard.library 2.0.3, and throw an error if there are no NETStandard2.0 package files to restore

<ExcludeRestorePackageImports>true</ExcludeRestorePackageImports>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="$(NetStandardLibraryPackage)" Version="$(NetStandardLibraryPackageVersion)" />
Copy link
Member

Choose a reason for hiding this comment

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

You might be able to get away with a hack to put this in tools.props as

    <PackageReference Include="$(NetStandardLibraryPackage)" Version="$(NetStandardLibraryPackageVersion)" ExcludeAssets="All" />

Copy link
Member

Choose a reason for hiding this comment

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

@wtgodbe I agree with Eric. A PackageReference in Tools.props would be cleaner.

@wtgodbe
Copy link
Member Author

wtgodbe commented Jan 15, 2019

@ericstj casing wasn't the issue, the Linux build is failing with https://github.com/dotnet/standard/pull/1047/files#diff-2fd532b34b8b1db3ee2c2ad7008d692eR43 & I thought maybe it was a casing issue. Do you think it's ok to disable that Target for non-Windows builds? As far as I can tell from the binlog (from DNCEng), the paths look good to me

@ericstj
Copy link
Member

ericstj commented Jan 16, 2019

Looks to me like it might be coming from the fallback folder. I see lots of NuGetFallbackFolder messages in the log. Elsewhere we've fixed such issues by doing stuff like this: https://github.com/dotnet/arcade/blob/289a8e607ef2a7358c351ddf3d08056186d4e554/src/Microsoft.DotNet.Build.Tasks.Packaging/tests/Microsoft.DotNet.Build.Tasks.Packaging.Tests.csproj#L38. I'm guessing you could hit the same issue on Windows if the machine had a fallback folder installed. We could just disable fallback folders for this repo. Since it doesn't consume a ton of packages that seems reasonable. To do that you'd make a change like this: https://github.com/dotnet/corefx/blob/f84927d4a85444e63ede2da38a49eff7116790db/NuGet.config#L5-L7

@wtgodbe
Copy link
Member Author

wtgodbe commented Jan 16, 2019

I'm still seeing the same error with the Fallback folder fix, looking

@wtgodbe
Copy link
Member Author

wtgodbe commented Jan 16, 2019

We're green! Anything else I should address @ViktorHofer @ericstj ?

Copy link
Member

@ViktorHofer ViktorHofer left a comment

Choose a reason for hiding this comment

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

Besides the one comment LGTM.

@wtgodbe
Copy link
Member Author

wtgodbe commented Jan 16, 2019

@ViktorHofer @ericstj I updated this to use a PackageReference in Tools.props, everything works locally. Will wait for CI then merge.

@wtgodbe wtgodbe merged commit e0a2e8e into dotnet:master Jan 16, 2019
@karelz karelz added this to the .NET Standard 2.1 milestone Jul 17, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bump version of .NET Standard to 2.1
6 participants