msbuild icon indicating copy to clipboard operation
msbuild copied to clipboard

Update to net7.0

Open benvillalobos opened this issue 2 years ago • 12 comments

Fixes #

Context

Changes Made

Testing

Notes

This will be chipped away at over time.

benvillalobos avatar Jul 05 '22 21:07 benvillalobos

I would think about updating Arcade first, then our TF.

rainersigwald avatar Jul 06 '22 16:07 rainersigwald

Hey @rainersigwald, @BenVillalobos, this will be needed for source-build in 7.0. I was testing this locally before I saw this PR, I am hitting the same issues as the CI here. Is there anything I can do to help move this along?

lbussell avatar Jul 19 '22 23:07 lbussell

@lbussell We're in early stages of working on this (Read: I'm poking at this when I have time 🙃). If you'd like to poke at it and offer some commits we can cherry-pick onto this branch, you're more than welcome! Feel free to PM me directly on this

benvillalobos avatar Jul 19 '22 23:07 benvillalobos

I pushed the branch I was working on to here. The only thing I tried differently was adding nowarn for some of the SYSLIB errors, which gave more errors: msbuild.txt

lbussell avatar Jul 20 '22 16:07 lbussell

@lbussell I cherry-picked your commit to resolve the future issues you were seeing. The "This type is not part of the declared API" wasn't showing up for me. Typically when those come up (which they shouldn't here?) you just do the VS suggested action of adding them to some Public.Shipped.API.txt file. Good news is I got a green build after that! Pushing it up to see if tests fail.

As for the issue that was nowarn'd around, it looks like the deprecations to AssemblyName are going to require us to rethink our use of AssemblyName. It looks like we use AssemblyName to gather information about the generated binaries. https://github.com/dotnet/runtime/issues/59061#issuecomment-922392861 suggests looking into the System.Reflection.Metadata namespace for gathering assembly info. Even if we could do that, it looks like we shouldn't use AssemblyName anymore, or we may need to create our own type.

The main culprits that need this type look like ResolveAssemblyReference and BinaryTranslator.

Based on my (very) brief investigation, I don't think working around AssemblyName is a reasonable thing to get volunteer work on, though we appreciate the offer! 😭

Realistically, I suspect we'll be able to dig in more early next week.

benvillalobos avatar Jul 20 '22 19:07 benvillalobos

Not sure what's going on with CI, I don't see these errors locally

benvillalobos avatar Jul 26 '22 21:07 benvillalobos

Thinking about this some. Our build defines the netstandard/netcore public shipped API txt files to be the same. Now that we're moving to net7.0, technically none of the API's in "netstandard" have been shipped yet because we haven't shipped these API's in net7.0.

Not 100% sure this is what's happening under the hood, but I'm going to clear out public api's shipped txt under netstandard and have VS fix it back into unshipped.

benvillalobos avatar Jul 26 '22 21:07 benvillalobos

That shouldn't be the problem but heck if I know what the actual problem is (doesn't repro on my machine either).

rainersigwald avatar Jul 26 '22 21:07 rainersigwald

Specifically removing the API's causing errors and having VS resolve them doesn't fix it.

Marking functions as public "because the analyzer didn't see it" doesn't resolve it either

benvillalobos avatar Jul 26 '22 22:07 benvillalobos

@sharwell any guidance here? API's are clearly public, but the analyzers are complaining about them. Maybe I'm missing something

benvillalobos avatar Jul 27 '22 17:07 benvillalobos

Preventing the warning from AssemblyName's ProcessorArchitecture being deprecated will make our caches not deserialize properly. Solution: delete the cache once (or just build again, since it should just be a warning), and it'll work the second time.

Forgind avatar Aug 02 '22 18:08 Forgind

@Forgind 's commits for future reference: https://github.com/forgind/msbuild/tree/net7.0-here-we-go

benvillalobos avatar Aug 03 '22 23:08 benvillalobos

@sharwell any guidance here? API's are clearly public, but the analyzers are complaining about them. Maybe I'm missing something

@jaredpar I just realized @sharlwell is oof, any ideas?

benvillalobos avatar Aug 12 '22 23:08 benvillalobos

You're running afoul of a bug in the new ref safety rules. It is upset about this constructor:

https://github.com/dotnet/msbuild/blob/3a92cefaf053c9377037d0af0c67736867cc9711/src/StringTools/InternableString.cs#L36

It believes the ctor may capture the parameter by ref. This is actually a bug in the current toolset. The RC SDK will compile this without error. Short term you can mark the reference as scoped ref and it will fix the problem.

jaredpar avatar Aug 13 '22 00:08 jaredpar

Why use AssemblyName over Assembly.GetName().Name or .FullName?

AraHaan avatar Aug 19 '22 04:08 AraHaan

@AraHaan /shrug. We could change that, but there's still the task of obtaining the processor architecture, which we're exploring how to do in a reasonable way: https://github.com/dotnet/runtime/issues/74040

benvillalobos avatar Aug 19 '22 19:08 benvillalobos

@AraHaan /shrug. We could change that, but there's still the task of obtaining the processor architecture, which we're exploring how to do in a reasonable way: dotnet/runtime#74040

So basically getting the architecture of the assembly itself + the .NET Host (to compare and prevent loading the wrong architecture in the host architecture)?

AraHaan avatar Aug 19 '22 23:08 AraHaan

I've simplified things a bit for future generations: Most places that needed a manual change from 6 to 7 was replaced with a single property. I also added a comment including relevant places to modify when updating to net8.0+

benvillalobos avatar Aug 19 '22 23:08 benvillalobos

On the comment will you need to update those files in the PR as well (the ones mentioned on it).

AraHaan avatar Aug 19 '22 23:08 AraHaan

@AraHaan Yep!

Edit: Unfortunately they're scripts and it's nontrivial to have an msbuild property flow into those.

benvillalobos avatar Aug 19 '22 23:08 benvillalobos

Hi @BenVillalobos, what's the status of this? Can it be merged soon? Thanks!

lbussell avatar Sep 06 '22 17:09 lbussell

This is not currently planned, because it breaks an SDK invariant (SDK tools should target LTS .NET). We have a meeting coming up to discuss a path forward with various stakeholders.

rainersigwald avatar Sep 06 '22 17:09 rainersigwald

@rainersigwald Please consider adding the source-build team to the meeting if it's appropriate (myself, @crummel, @MichaelSimons). We were hoping to get this change in for RC2.

lbussell avatar Sep 06 '22 18:09 lbussell

This is not currently planned, because it breaks an SDK invariant (SDK tools should target LTS .NET). We have a meeting coming up to discuss a path forward with various stakeholders.

I think it should be on for the .NET 7 SDK only, but yeah I would be ok with it targeting LTS for LTS sdk builds.

AraHaan avatar Sep 07 '22 16:09 AraHaan

@BenVillalobos @rainersigwald @jaredpar, from the discussion we had in the meeting, is the plan now to merge this to flush out any potential issues going forwards?

lbussell avatar Sep 16 '22 16:09 lbussell

Yes, this is now The Plan again. ETA next week, hopefully early.

rainersigwald avatar Sep 16 '22 16:09 rainersigwald

Internal official build for good measure https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=6700270&view=results

rainersigwald avatar Sep 16 '22 20:09 rainersigwald

Just went over this with @rainersigwald, this looks good to go 👍

benvillalobos avatar Sep 19 '22 18:09 benvillalobos

Potential workaround for our roslyn analyzer issue: https://github.com/dotnet/msbuild/issues/7903

benvillalobos avatar Sep 19 '22 18:09 benvillalobos

@lbussell I suspect sourcebuild will also want us on Arcade 7 and I'm working on that migration now.

rainersigwald avatar Sep 19 '22 18:09 rainersigwald