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

MSBuild Upgrade: netstandard2.0 -> net6.0 #6148

Merged
merged 60 commits into from
Mar 7, 2022

Conversation

benvillalobos
Copy link
Member

@benvillalobos benvillalobos commented Feb 11, 2021

Fixes #6032

Context

While we're in the process of updating target frameworks, let's move off of netstandard2.0.

EXCEPT: We need two projects (M.B.Framework and M.B.Utilities) to build as ns2.0 and place their ref assemblies under OutputPath/ref for the RoslynCodeTaskFactory.

Changes Made

Changed TargetLibraryFrameworks to include net6.0
Add a target for ns2.0 builds to place M.B.Framework and Utilities ref assemblies into the build's ref/ folder.

Marked various tasks (Particularly SignFile) with a "Windows" OS Attribute

Testing

CI and local builds pass.

Notes

Review by diff!

@benvillalobos
Copy link
Member Author

@Forgind do you recognize the issue with System.Configuration? It's pointing to RAR suggesting there are multiple references to that binary. Pinging you because I'm still a RAR newbie ¯_(ツ)_/¯

@Forgind
Copy link
Member

Forgind commented Feb 11, 2021

Just looking at the list of Windows Core errors, there were a variety of different problems here, only two of which are related to RAR. If you can get a diagnostic build log or binlog, I can probably find where conflict is coming from—it looks like some assemblies refer to a specific version (4.0.0.0) of System.Configuration, whereas some other refers to it without a version, and RAR was confused. Unfortunately, only one binlog (Windows Full) output a binlog, as far as I can tell, and that one didn't have that problem, so I don't have much else to go on.

Are you seeing this problem locally? If so, I can try pulling it down and looking into it.

@benvillalobos
Copy link
Member Author

@Forgind I think it was due to multiple <Reference's to the same package. I needed to change a condition.

@benvillalobos
Copy link
Member Author

benvillalobos commented Mar 2, 2021

@ladipro running eng\cibuild_bootstrapped_msbuild.cmd from this branch sees about a dozen errors, two of them being related to stringtools. Interestingly enough they don't show up in git CI.

Note that this PR updated LibraryTargetFrameworks to include net5.0 instead of netstandard2.0, so stringtools is updated.

in Microsoft.NET.StringTools.Tests.WeakStringCache_Tests.RetainsLastStringWithGivenHashCode

Microsoft.NET.StringTools.Tests.WeakStringCache_Tests.RetainsLastStringWithGivenHashCode
Shouldly.ShouldAssertException : \"Random string 1\"\n    should be same as\n\"Random string 1\"\n    but was not
   at Shouldly.ShouldlyCoreExtensions.AssertAwesomely[T](T actual, Func`2 specifiedConstraint, Object originalActual, Object originalExpected, Func`1 customMessage, String shouldlyMethod)
   at Shouldly.ShouldBeTestExtensions.ShouldBeSameAs(Object actual, Object expected, Func`1 customMessage)
   at Shouldly.ShouldBeTestExtensions.ShouldBeSameAs(Object actual, Object expected)
   at Microsoft.NET.StringTools.Tests.WeakStringCache_Tests.AddString(String strPart1, String strPart2, Action`1 callbackToRunWithTheStringAlive) in C:\src\git\msbuild\src\StringTools.UnitTests\WeakStringCache_Tests.cs:line 52
   at Microsoft.NET.StringTools.Tests.WeakStringCache_Tests.AddStringsWithSameHashCode(Int32 numberOfStrings) in C:\src\git\msbuild\src\StringTools.UnitTests\WeakStringCache_Tests.cs:line 88
   at Microsoft.NET.StringTools.Tests.WeakStringCache_Tests.RetainsLastStringWithGivenHashCode() in C:\src\git\msbuild\src\StringTools.UnitTests\WeakStringCache_Tests.cs:line 172

and Microsoft.NET.StringTools.Tests.WeakStringCache_Tests.RetainsStringUntilCollected

Shouldly.ShouldAssertException : \"Random string test\"\n    should be same as\n\"Random string test\"\n    but was not
   at Shouldly.ShouldlyCoreExtensions.AssertAwesomely[T](T actual, Func`2 specifiedConstraint, Object originalActual, Object originalExpected, Func`1 customMessage, String shouldlyMethod)
   at Shouldly.ShouldBeTestExtensions.ShouldBeSameAs(Object actual, Object expected, Func`1 customMessage)
   at Shouldly.ShouldBeTestExtensions.ShouldBeSameAs(Object actual, Object expected)
   at Microsoft.NET.StringTools.Tests.WeakStringCache_Tests.AddString(String strPart1, String strPart2, Action`1 callbackToRunWithTheStringAlive) in C:\src\git\msbuild\src\StringTools.UnitTests\WeakStringCache_Tests.cs:line 52
   at Microsoft.NET.StringTools.Tests.WeakStringCache_Tests.RetainsStringUntilCollected() in C:\src\git\msbuild\src\StringTools.UnitTests\WeakStringCache_Tests.cs:line 130

Any idea why going from netstandard2.0 to net5.0 would break these specific tests?

Also please double check commit bc7c4e1, I had to relax some nullable warnings.

@benvillalobos
Copy link
Member Author

benvillalobos commented Mar 2, 2021

@dsplaisted could you take a look at 8bbdc98? I'm not sure how to go adding these ref assemblies, or if we even need them anymore if we're updating to net5.0.

I took a wild guess and I didn't get lucky 🙂

I tried removing it entirely to see what would happen and I'm seeing:

Microsoft.Build.Tasks.UnitTests.RoslynCodeTaskFactory_Tests.RoslynCodeTaskFactory_ReuseCompilation
Shouldly.ShouldAssertException : BuildProject(globalProperties, toolsVersion, out MockLogger logger)\n    should be\nTrue\n    but was\nFalse
   at Shouldly.ShouldBeBooleanExtensions.ShouldBeTrue(Boolean actual, Func`1 customMessage)
   at Shouldly.ShouldBeBooleanExtensions.ShouldBeTrue(Boolean actual)
   at Microsoft.Build.UnitTests.TransientTestProjectWithFiles.BuildProjectExpectSuccess(IDictionary`2 globalProperties, String toolsVersion) in C:\src\git\msbuild\src\Shared\UnitTests\EngineTestEnvironment.cs:line 130
   at Microsoft.Build.Tasks.UnitTests.RoslynCodeTaskFactory_Tests.RoslynCodeTaskFactory_ReuseCompilation() in C:\src\git\msbuild\src\Tasks.UnitTests\RoslynCodeTaskFactory_Tests.cs:line 80

I don't suppose this is expected, given that the commit I linked modified the AddRefAssemblies target that's meant for the roslyn code task factory.

@benvillalobos
Copy link
Member Author

benvillalobos commented Mar 2, 2021

Am I seeing things, or is this project also failing at UndeclaredReferenceEnforcementShouldFailOnPreviouslyBuiltButUndeclaredReferences, just like #6174?
nevermind this. Misreading intentional build failures as test failures, which they're not.

Copy link
Member

@ladipro ladipro left a comment

Choose a reason for hiding this comment

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

@benvillalobos please cherry-pick ladipro@4984166 to fix the failing StringTools tests.


private bool ShouldSkip(HttpResponseMessage response, FileInfo destinationFile)
private bool ShouldSkip(HttpResponseMessage response, FileInfo destinationFile)
Copy link
Member

Choose a reason for hiding this comment

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

nit: Looks like an unintended whitespace change.

@benvillalobos
Copy link
Member Author

benvillalobos commented Mar 3, 2021

@KirillOsenkov you were the last to modify RoslynCodeTaskFactory_ReuseCompilation relatively recently and it's failing in CI. Any idea why it's failing off the top of your head?

Also see #6148 (comment), I'm not entirely sure what to do with AddRefAssemblies. My impression at the moment is to construct a property that properly defines a path relative to each flavor OS.

@dsplaisted
Copy link
Member

@benvillalobos You should be able to write a target that filters out those assemblies from what's resolved from the targeting packs instead of hardcoding the path.

However, the .NET Core / .NET 5 versions of those assemblies may be different than reference assemblies of those for .NET Standard, so I'm not sure if they'll work anyway.

@benvillalobos
Copy link
Member Author

@dsplaisted can you point me in the right direction for any properties set via these targeting packs that would help me accomplish this?

@dsplaisted
Copy link
Member

@benvillalobos I'm saying you would filter out the items that come out of ResolveTargetingPackAssets based on filename. So you'd look for netstandard.dll and mscorlib.dll.

However, I'm also not sure if the versions of those in the .NET 5 targeting pack will work for this or not.

benvillalobos added a commit to benvillalobos/msbuild that referenced this pull request Mar 8, 2021
Base automatically changed from master to main March 15, 2021 20:09
@benvillalobos
Copy link
Member Author

Did a test by hardcoding the dll's from the targeting packs:
image

It doesn't error on copying the assembly, but this RoslynCodeTaskFactory test still fails

Microsoft.Build.Tasks.UnitTests.RoslynCodeTaskFactory_Tests.RoslynCodeTaskFactory_ReuseCompilation
Shouldly.ShouldAssertException : BuildProject(globalProperties, toolsVersion, out MockLogger logger)\n    should be\nTrue\n    but was\nFalse
   at Shouldly.ShouldBeBooleanExtensions.ShouldBeTrue(Boolean actual, Func`1 customMessage)
   at Shouldly.ShouldBeBooleanExtensions.ShouldBeTrue(Boolean actual)
   at Microsoft.Build.UnitTests.TransientTestProjectWithFiles.BuildProjectExpectSuccess(IDictionary`2 globalProperties, String toolsVersion) in C:\src\git\msbuild\src\Shared\UnitTests\EngineTestEnvironment.cs:line 130
   at Microsoft.Build.Tasks.UnitTests.RoslynCodeTaskFactory_Tests.RoslynCodeTaskFactory_ReuseCompilation() in C:\src\git\msbuild\src\Tasks.UnitTests\RoslynCodeTaskFactory_Tests.cs:line 80

@benvillalobos
Copy link
Member Author

Also seeing these failures:

 Microsoft.Build.Graph.UnitTests.IsolateProjectsTests.CacheEnforcementShouldAcceptPreviouslyBuiltReferences(targetName: \"BuildDeclaredReferenceViaTask\")
Shouldly.ShouldAssertException : result.OverallResult\n    should be\nBuildResultCode.Success\n    but was\r\nBuildResultCode.Failure
   at Shouldly.ShouldlyCoreExtensions.AssertAwesomely[T](T actual, Func`2 specifiedConstraint, Object originalActual, Object originalExpected, Func`1 customMessage, String shouldlyMethod)
   at Shouldly.ShouldBeTestExtensions.ShouldBe[T](T actual, T expected, Func`1 customMessage)
   at Shouldly.ShouldBeTestExtensions.ShouldBe[T](T actual, T expected)
   at Microsoft.Build.Graph.UnitTests.IsolateProjectsTests.<>c.<CacheEnforcementShouldAcceptPreviouslyBuiltReferences>b__15_0(BuildResult result, MockLogger logger) in C:\src\git\msbuild\src\Build.UnitTests\Graph\IsolateProjects_Tests.cs:line 276
   at Microsoft.Build.Graph.UnitTests.IsolateProjectsTests.AssertBuild(String[] targets, Action`2 assert, Boolean buildDeclaredReference, Boolean buildUndeclaredReference, Boolean addContinueOnError, Boolean excludeReferencesFromConstraints, Boolean isolateProjects, Func`2 projectReferenceModifier, Func`2 msbuildOnDeclaredReferenceModifier) in C:\src\git\msbuild\src\Build.UnitTests\Graph\IsolateProjects_Tests.cs:line 430
   at Microsoft.Build.Graph.UnitTests.IsolateProjectsTests.CacheEnforcementShouldAcceptPreviouslyBuiltReferences(String targetName) in C:\src\git\msbuild\src\Build.UnitTests\Graph\IsolateProjects_Tests.cs:line 273
Output:
Build started.
Evaluation started ("C:\Users\bevillal\AppData\Local\Temp\3pfzsczs.vmg\tmp65ec6b558a8a426499af30d691017ab9.tmp")
Evaluation finished ("C:\Users\bevillal\AppData\Local\Temp\3pfzsczs.vmg\tmp65ec6b558a8a426499af30d691017ab9.tmp")
Project "tmp65ec6b558a8a426499af30d691017ab9.tmp" (DeclaredReferenceTarget target(s)):
Building with tools version "Current".
Target "DeclaredReferenceTarget" in project "C:\Users\bevillal\AppData\Local\Temp\3pfzsczs.vmg\tmp65ec6b558a8a426499af30d691017ab9.tmp" (entry point):
Using "Message" task from assembly "Microsoft.Build.Tasks.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
Task "Message"
Message from reference
Done executing task "Message".
Done building target "DeclaredReferenceTarget" in project "tmp65ec6b558a8a426499af30d691017ab9.tmp".
Done building project "tmp65ec6b558a8a426499af30d691017ab9.tmp".
Evaluation started ("C:\Users\bevillal\AppData\Local\Temp\3pfzsczs.vmg\tmp584f86bd1bcc480eb9a1066fdbbf8590.tmp")
Evaluation finished ("C:\Users\bevillal\AppData\Local\Temp\3pfzsczs.vmg\tmp584f86bd1bcc480eb9a1066fdbbf8590.tmp")
Project "tmp584f86bd1bcc480eb9a1066fdbbf8590.tmp" (BuildDeclaredReferenceViaTask target(s)):
Building with tools version "Current".
Target "BuildDeclaredReferenceViaTask" in project "C:\Users\bevillal\AppData\Local\Temp\3pfzsczs.vmg\tmp584f86bd1bcc480eb9a1066fdbbf8590.tmp" (entry point):
Initializing task factory "RoslynCodeTaskFactory" from assembly "C:\src\git\msbuild\artifacts\bin\Microsoft.Build.Engine.UnitTests\Debug\net472\Microsoft.Build.Tasks.Core.dll".
Compiling task source code
C:\src\git\msbuild\artifacts\bin\Microsoft.Build.Engine.UnitTests\Debug\net472\Roslyn\csc.exe /noconfig /reference:C:\src\git\msbuild\artifacts\bin\Microsoft.Build.Engine.UnitTests\Debug\net472\Microsoft.Build.Framework.dll /reference:C:\src\git\msbuild\artifacts\bin\Microsoft.Build.Engine.UnitTests\Debug\net472\Microsoft.Build.Utilities.Core.dll /reference:C:\src\git\msbuild\artifacts\bin\Microsoft.Build.Engine.UnitTests\Debug\net472\ref\mscorlib.dll /reference:C:\src\git\msbuild\artifacts\bin\Microsoft.Build.Engine.UnitTests\Debug\net472\ref\netstandard.dll /deterministic+ /nologo /optimize- /target:Library /out:C:\Users\bevillal\AppData\Local\Temp\3pfzsczs.vmg\giru15b3.uqw.dll C:\Users\bevillal\AppData\Local\Temp\3pfzsczs.vmg\tmp8C31.tmp /nostdlib+ 
tmp8C31.tmp(22,34):  error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
tmp8C31.tmp(30,13):  error CS0518: Predefined type 'System.Void' is not defined or imported
tmp8C31.tmp(41,13):  error CS0518: Predefined type 'System.Void' is not defined or imported
tmp8C31.tmp(52,13):  error CS0518: Predefined type 'System.Void' is not defined or imported
tmp8C31.tmp(57,25):  error CS0518: Predefined type 'System.Boolean' is not defined or imported
tmp8C31.tmp(57,30):  error CS0518: Predefined type 'System.Boolean' is not defined or imported
tmp8C31.tmp(24,17):  error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
tmp8C31.tmp(24,17):  error CS0518: Predefined type 'System.Object' is not defined or imported
tmp8C31.tmp(35,17):  error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
tmp8C31.tmp(35,17):  error CS0518: Predefined type 'System.Object' is not defined or imported
tmp8C31.tmp(46,17):  error CS0518: Predefined type 'System.Boolean' is not defined or imported
tmp8C31.tmp(26,24):  error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
tmp8C31.tmp(26,24):  error CS0518: Predefined type 'System.Object' is not defined or imported
tmp8C31.tmp(37,24):  error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
tmp8C31.tmp(37,24):  error CS0518: Predefined type 'System.Object' is not defined or imported
tmp8C31.tmp(48,24):  error CS0518: Predefined type 'System.Boolean' is not defined or imported
The command exited with code 1.
C:\Users\bevillal\AppData\Local\Temp\3pfzsczs.vmg\tmp584f86bd1bcc480eb9a1066fdbbf8590.tmp(84,25):  error : The source file for this compilation can be found at: "C:\Users\bevillal\AppData\Local\Temp\3pfzsczs.vmg\tmp8C31.tmp"
C:\Users\bevillal\AppData\Local\Temp\3pfzsczs.vmg\tmp584f86bd1bcc480eb9a1066fdbbf8590.tmp(84,25):  error MSB4175: The task factory "RoslynCodeTaskFactory" could not be loaded from the assembly "C:\src\git\msbuild\artifacts\bin\Microsoft.Build.Engine.UnitTests\Debug\net472\Microsoft.Build.Tasks.Core.dll". 
This is an unhandled exception from a task factory-- PLEASE OPEN A BUG AGAINST THE TASK FACTORY OWNER. The task factory must return a value for the "TaskType" property.
Done building target "BuildDeclaredReferenceViaTask" in project "tmp584f86bd1bcc480eb9a1066fdbbf8590.tmp" -- FAILED.
Done building project "tmp584f86bd1bcc480eb9a1066fdbbf8590.tmp" -- FAILED.
Build FAILED.
4.8584935s✘ Microsoft.Build.Graph.UnitTests.IsolateProjectsTests.EnforcementsCanBeSkipped(targetName: \"BuildDeclaredReferenceViaTask\")
Shouldly.ShouldAssertException : result.OverallResult\n    should be\nBuildResultCode.Success\n    but was\r\nBuildResultCode.Failure
   at Shouldly.ShouldlyCoreExtensions.AssertAwesomely[T](T actual, Func`2 specifiedConstraint, Object originalActual, Object originalExpected, Func`1 customMessage, String shouldlyMethod)
   at Shouldly.ShouldBeTestExtensions.ShouldBe[T](T actual, T expected, Func`1 customMessage)
   at Shouldly.ShouldBeTestExtensions.ShouldBe[T](T actual, T expected)
   at Microsoft.Build.Graph.UnitTests.IsolateProjectsTests.<>c.<EnforcementsCanBeSkipped>b__14_0(BuildResult result, MockLogger logger) in C:\src\git\msbuild\src\Build.UnitTests\Graph\IsolateProjects_Tests.cs:line 254
   at Microsoft.Build.Graph.UnitTests.IsolateProjectsTests.AssertBuild(String[] targets, Action`2 assert, Boolean buildDeclaredReference, Boolean buildUndeclaredReference, Boolean addContinueOnError, Boolean excludeReferencesFromConstraints, Boolean isolateProjects, Func`2 projectReferenceModifier, Func`2 msbuildOnDeclaredReferenceModifier) in C:\src\git\msbuild\src\Build.UnitTests\Graph\IsolateProjects_Tests.cs:line 430
   at Microsoft.Build.Graph.UnitTests.IsolateProjectsTests.EnforcementsCanBeSkipped(String targetName) in C:\src\git\msbuild\src\Build.UnitTests\Graph\IsolateProjects_Tests.cs:line 250
Output:
Build started.
Evaluation started ("C:\Users\bevillal\AppData\Local\Temp\3pfzsczs.vmg\tmp6b3b2a4d4b85495f86a751e15cf32bca.tmp")
Evaluation finished ("C:\Users\bevillal\AppData\Local\Temp\3pfzsczs.vmg\tmp6b3b2a4d4b85495f86a751e15cf32bca.tmp")
Project "tmp6b3b2a4d4b85495f86a751e15cf32bca.tmp" (BuildDeclaredReferenceViaTask target(s)):
Building with tools version "Current".
Target "BuildDeclaredReferenceViaTask" in project "C:\Users\bevillal\AppData\Local\Temp\3pfzsczs.vmg\tmp6b3b2a4d4b85495f86a751e15cf32bca.tmp" (entry point):
Initializing task factory "RoslynCodeTaskFactory" from assembly "C:\src\git\msbuild\artifacts\bin\Microsoft.Build.Engine.UnitTests\Debug\net472\Microsoft.Build.Tasks.Core.dll".
Compiling task source code
C:\src\git\msbuild\artifacts\bin\Microsoft.Build.Engine.UnitTests\Debug\net472\Roslyn\csc.exe /noconfig /reference:C:\src\git\msbuild\artifacts\bin\Microsoft.Build.Engine.UnitTests\Debug\net472\Microsoft.Build.Framework.dll /reference:C:\src\git\msbuild\artifacts\bin\Microsoft.Build.Engine.UnitTests\Debug\net472\Microsoft.Build.Utilities.Core.dll /reference:C:\src\git\msbuild\artifacts\bin\Microsoft.Build.Engine.UnitTests\Debug\net472\ref\mscorlib.dll /reference:C:\src\git\msbuild\artifacts\bin\Microsoft.Build.Engine.UnitTests\Debug\net472\ref\netstandard.dll /deterministic+ /nologo /optimize- /target:Library /out:C:\Users\bevillal\AppData\Local\Temp\3pfzsczs.vmg\t2dzmyah.bsv.dll C:\Users\bevillal\AppData\Local\Temp\3pfzsczs.vmg\tmp4F52.tmp /nostdlib+ 
tmp4F52.tmp(22,34):  error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
tmp4F52.tmp(30,13):  error CS0518: Predefined type 'System.Void' is not defined or imported
tmp4F52.tmp(41,13):  error CS0518: Predefined type 'System.Void' is not defined or imported
tmp4F52.tmp(52,13):  error CS0518: Predefined type 'System.Void' is not defined or imported
tmp4F52.tmp(57,25):  error CS0518: Predefined type 'System.Boolean' is not defined or imported
tmp4F52.tmp(57,30):  error CS0518: Predefined type 'System.Boolean' is not defined or imported
tmp4F52.tmp(24,17):  error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
tmp4F52.tmp(24,17):  error CS0518: Predefined type 'System.Object' is not defined or imported
tmp4F52.tmp(35,17):  error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
tmp4F52.tmp(35,17):  error CS0518: Predefined type 'System.Object' is not defined or imported
tmp4F52.tmp(46,17):  error CS0518: Predefined type 'System.Boolean' is not defined or imported
tmp4F52.tmp(26,24):  error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
tmp4F52.tmp(26,24):  error CS0518: Predefined type 'System.Object' is not defined or imported
tmp4F52.tmp(37,24):  error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
tmp4F52.tmp(37,24):  error CS0518: Predefined type 'System.Object' is not defined or imported
tmp4F52.tmp(48,24):  error CS0518: Predefined type 'System.Boolean' is not defined or imported
The command exited with code 1.
C:\Users\bevillal\AppData\Local\Temp\3pfzsczs.vmg\tmp6b3b2a4d4b85495f86a751e15cf32bca.tmp(84,25):  error : The source file for this compilation can be found at: "C:\Users\bevillal\AppData\Local\Temp\3pfzsczs.vmg\tmp4F52.tmp"
C:\Users\bevillal\AppData\Local\Temp\3pfzsczs.vmg\tmp6b3b2a4d4b85495f86a751e15cf32bca.tmp(84,25):  error MSB4175: The task factory "RoslynCodeTaskFactory" could not be loaded from the assembly "C:\src\git\msbuild\artifacts\bin\Microsoft.Build.Engine.UnitTests\Debug\net472\Microsoft.Build.Tasks.Core.dll". 
This is an unhandled exception from a task factory-- PLEASE OPEN A BUG AGAINST THE TASK FACTORY OWNER. The task factory must return a value for the "TaskType" property.
Done building target "BuildDeclaredReferenceViaTask" in project "tmp6b3b2a4d4b85495f86a751e15cf32bca.tmp" -- FAILED.
Done building project "tmp6b3b2a4d4b85495f86a751e15cf32bca.tmp" -- FAILED.
Build FAILED.
5.3075131s✘ Microsoft.Build.Graph.UnitTests.IsolateProjectsTests.EnforcementsCanBeSkipped(targetName: \"BuildUndeclaredReferenceViaTask\")
Shouldly.ShouldAssertException : result.OverallResult\n    should be\nBuildResultCode.Success\n    but was\r\nBuildResultCode.Failure
   at Shouldly.ShouldlyCoreExtensions.AssertAwesomely[T](T actual, Func`2 specifiedConstraint, Object originalActual, Object originalExpected, Func`1 customMessage, String shouldlyMethod)
   at Shouldly.ShouldBeTestExtensions.ShouldBe[T](T actual, T expected, Func`1 customMessage)
   at Shouldly.ShouldBeTestExtensions.ShouldBe[T](T actual, T expected)
   at Microsoft.Build.Graph.UnitTests.IsolateProjectsTests.<>c.<EnforcementsCanBeSkipped>b__14_0(BuildResult result, MockLogger logger) in C:\src\git\msbuild\src\Build.UnitTests\Graph\IsolateProjects_Tests.cs:line 254
   at Microsoft.Build.Graph.UnitTests.IsolateProjectsTests.AssertBuild(String[] targets, Action`2 assert, Boolean buildDeclaredReference, Boolean buildUndeclaredReference, Boolean addContinueOnError, Boolean excludeReferencesFromConstraints, Boolean isolateProjects, Func`2 projectReferenceModifier, Func`2 msbuildOnDeclaredReferenceModifier) in C:\src\git\msbuild\src\Build.UnitTests\Graph\IsolateProjects_Tests.cs:line 430
   at Microsoft.Build.Graph.UnitTests.IsolateProjectsTests.EnforcementsCanBeSkipped(String targetName) in C:\src\git\msbuild\src\Build.UnitTests\Graph\IsolateProjects_Tests.cs:line 250
Output:
Build started.
Evaluation started ("C:\Users\bevillal\AppData\Local\Temp\3pfzsczs.vmg\tmpedd754e032784f7ea14567cafdadb021.tmp")
Evaluation finished ("C:\Users\bevillal\AppData\Local\Temp\3pfzsczs.vmg\tmpedd754e032784f7ea14567cafdadb021.tmp")
Project "tmpedd754e032784f7ea14567cafdadb021.tmp" (BuildUndeclaredReferenceViaTask target(s)):
Building with tools version "Current".
Target "BuildUndeclaredReferenceViaTask" in project "C:\Users\bevillal\AppData\Local\Temp\3pfzsczs.vmg\tmpedd754e032784f7ea14567cafdadb021.tmp" (entry point):
Initializing task factory "RoslynCodeTaskFactory" from assembly "C:\src\git\msbuild\artifacts\bin\Microsoft.Build.Engine.UnitTests\Debug\net472\Microsoft.Build.Tasks.Core.dll".
Compiling task source code
C:\src\git\msbuild\artifacts\bin\Microsoft.Build.Engine.UnitTests\Debug\net472\Roslyn\csc.exe /noconfig /reference:C:\src\git\msbuild\artifacts\bin\Microsoft.Build.Engine.UnitTests\Debug\net472\Microsoft.Build.Framework.dll /reference:C:\src\git\msbuild\artifacts\bin\Microsoft.Build.Engine.UnitTests\Debug\net472\Microsoft.Build.Utilities.Core.dll /reference:C:\src\git\msbuild\artifacts\bin\Microsoft.Build.Engine.UnitTests\Debug\net472\ref\mscorlib.dll /reference:C:\src\git\msbuild\artifacts\bin\Microsoft.Build.Engine.UnitTests\Debug\net472\ref\netstandard.dll /deterministic+ /nologo /optimize- /target:Library /out:C:\Users\bevillal\AppData\Local\Temp\3pfzsczs.vmg\0qta3af2.i4z.dll C:\Users\bevillal\AppData\Local\Temp\3pfzsczs.vmg\tmp678D.tmp /nostdlib+ 
tmp678D.tmp(22,34):  error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
tmp678D.tmp(30,13):  error CS0518: Predefined type 'System.Void' is not defined or imported
tmp678D.tmp(41,13):  error CS0518: Predefined type 'System.Void' is not defined or imported
tmp678D.tmp(52,13):  error CS0518: Predefined type 'System.Void' is not defined or imported
tmp678D.tmp(57,25):  error CS0518: Predefined type 'System.Boolean' is not defined or imported
tmp678D.tmp(57,30):  error CS0518: Predefined type 'System.Boolean' is not defined or imported
tmp678D.tmp(24,17):  error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
tmp678D.tmp(24,17):  error CS0518: Predefined type 'System.Object' is not defined or imported
tmp678D.tmp(35,17):  error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
tmp678D.tmp(35,17):  error CS0518: Predefined type 'System.Object' is not defined or imported
tmp678D.tmp(46,17):  error CS0518: Predefined type 'System.Boolean' is not defined or imported
tmp678D.tmp(26,24):  error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
tmp678D.tmp(26,24):  error CS0518: Predefined type 'System.Object' is not defined or imported
tmp678D.tmp(37,24):  error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
tmp678D.tmp(37,24):  error CS0518: Predefined type 'System.Object' is not defined or imported
tmp678D.tmp(48,24):  error CS0518: Predefined type 'System.Boolean' is not defined or imported
The command exited with code 1.
C:\Users\bevillal\AppData\Local\Temp\3pfzsczs.vmg\tmpedd754e032784f7ea14567cafdadb021.tmp(88,25):  error : The source file for this compilation can be found at: "C:\Users\bevillal\AppData\Local\Temp\3pfzsczs.vmg\tmp678D.tmp"
C:\Users\bevillal\AppData\Local\Temp\3pfzsczs.vmg\tmpedd754e032784f7ea14567cafdadb021.tmp(88,25):  error MSB4175: The task factory "RoslynCodeTaskFactory" could not be loaded from the assembly "C:\src\git\msbuild\artifacts\bin\Microsoft.Build.Engine.UnitTests\Debug\net472\Microsoft.Build.Tasks.Core.dll". 
This is an unhandled exception from a task factory-- PLEASE OPEN A BUG AGAINST THE TASK FACTORY OWNER. The task factory must return a value for the "TaskType" property.
Done building target "BuildUndeclaredReferenceViaTask" in project "tmpedd754e032784f7ea14567cafdadb021.tmp" -- FAILED.
Done building project "tmpedd754e032784f7ea14567cafdadb021.tmp" -- FAILED.
Build FAILED.
2.2269549s✘ Microsoft.Build.UnitTests.BackEnd.TaskHost_Tests.TasksCanGetGlobalProperties
Assert.True() Failure\r\nExpected: True\r\nActual:   False
   at Microsoft.Build.UnitTests.Helpers.BuildProjectWithNewOMExpectSuccess(String content, Dictionary`2 globalProperties, MockLogger logger) in C:\src\git\msbuild\src\Shared\UnitTests\ObjectModelHelpers.cs:line 1312
   at Microsoft.Build.UnitTests.BackEnd.TaskHost_Tests.TasksCanGetGlobalProperties() in C:\src\git\msbuild\src\Build.UnitTests\BackEnd\TaskHost_Tests.cs:line 673
2.1910045s✘ Microsoft.Build.UnitTests.BackEnd.TaskHost_Tests.TasksGetNoGlobalPropertiesIfNoneSpecified
Assert.True() Failure\r\nExpected: True\r\nActual:   False
   at Microsoft.Build.UnitTests.Helpers.BuildProjectWithNewOMExpectSuccess(String content, Dictionary`2 globalProperties, MockLogger logger) in C:\src\git\msbuild\src\Shared\UnitTests\ObjectModelHelpers.cs:line 1312
   at Microsoft.Build.UnitTests.BackEnd.TaskHost_Tests.TasksGetNoGlobalPropertiesIfNoneSpecified() in C:\src\git\msbuild\src\Build.UnitTests\BackEnd\TaskHost_Tests.cs:line 703

Some of these test failures have to do with the net472 mscorlib/netstandard dll's

@marcpopMSFT marcpopMSFT added this to In progress in 17.0 May 3, 2021
@marcpopMSFT marcpopMSFT added this to the 17.0 milestone May 13, 2021
@Forgind
Copy link
Member

Forgind commented Jun 1, 2021

Any recent progress on this? Would be nice to finish it or close it until you're ready to come back to it.

@benvillalobos benvillalobos force-pushed the netstandard2.0-to-net5.0 branch 2 times, most recently from 89f2221 to 8ffe79f Compare June 7, 2021 23:33
Copy link
Member

@rainersigwald rainersigwald left a comment

Choose a reason for hiding this comment

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

Sorry for the random drive-by review of a draft PR . . .

@@ -25,7 +25,7 @@
<PackageReference Include="System.Configuration.ConfigurationManager" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFrameworkIdentifier)' != '.NETStandard'">
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">
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 get a !MONO?

@@ -36,6 +39,9 @@ public SignFile()

public string TimestampUrl { get; set; }

#if RUNTIME_TYPE_NETCORE
[SupportedOSPlatform("windows")]
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this should propagate quite so far. If we're going to expose the task we should expose it everywhere and emit good error messages if we hit a non-windows-compat codepath.

Copy link
Member Author

Choose a reason for hiding this comment

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

I removed it from the Execute and appreciate this new way better than how it was. I'm not sure if we should go in and log errors in other areas where I applied SupportedOSPlatform? I think it makes sense to keep the static SignFile methods with this attribute, at least.

src/StringTools/InternableString.cs Outdated Show resolved Hide resolved
@@ -37,7 +37,7 @@ public string GetOrCreateEntry(ref InternableString internable, out bool cacheHi

// Get the existing handle from the cache and lock it while we're dereferencing it to prevent a race with the Scavenge
// method running on another thread and freeing the handle from underneath us.
if (_stringsByHashCode.TryGetValue(hashCode, out handle))
if (_stringsByHashCode.TryGetValue(hashCode, out handle!))
Copy link
Member

Choose a reason for hiding this comment

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

I think a better fix for this would be changing the definition of handle above to StringWeakHandle?

src/Tasks/DownloadFile.cs Outdated Show resolved Hide resolved
@benvillalobos
Copy link
Member Author

Investigation notes on ResourceManagement_Tests for the day:

Something is up with the net6.0 version of Microsoft.Build.Tasks.Core.dll, but I don't think the assembly itself. When running dotnet build on the generated project:

<Project>
  <UsingTask
    TaskName="UseCores"
    TaskFactory="RoslynCodeTaskFactory"
    AssemblyFile="C:\src\git\msbuild\artifacts\bin\Microsoft.Build.Tasks.UnitTests\Debug\net6.0\Microsoft.Build.Tasks.Core.dll" >
    <Task>
      <Reference Include="C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.0-preview.3.21201.4\System.Runtime.dll" />
      <Reference Include="C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll" />
      <Code Type="Fragment" Language="cs">
        
                {
                    System.Console.WriteLine("DEBUG");
                }
      </Code>
    </Task>
  </UsingTask>

  <Target Name="Build">
        <UseCores />
  </Target>
</Project>

RoslynCodeTaskFactory attempts to build the generated source file:

//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:6.0.0
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace InlineCode {
    using Microsoft.Build.Framework;
    using Microsoft.Build.Utilities;
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    using System.Text;
    
    
    public class UseCores : Microsoft.Build.Utilities.Task {
        
        private bool _Success = true;
        
        public virtual bool Success {
            get {
                return _Success;
            }
            set {
                _Success = value;
            }
        }
        
        public override bool Execute() {

        
                {
                    System.Console.WriteLine("DEBUG");
                }
      
            return Success;
        }
    }
}

On deeper investigation, it passes the following references when trying to build:
image

In a successful run (in VS unit tests), it passes the following:
image

Messing around with the references passed into compilation, it always fails when passing the net6.0 version of Microsoft.Build.Utilities.Core.dll, so I can only assume something is up with that dll. What it is, I'm not sure yet.

@rainersigwald
Copy link
Member

Seeing it written out like that made me go 💡.

You're saying that Microsoft.Build.Utilities.Core.dll is the problem, right? And we're now building that against net6.0. So it has "real" references to net6 versions of everything.

Possibilities:

  1. Don't change that assembly (all assemblies?) away from netstandard2.0
  2. Build a netstandard2.0 version of the ref assembly for our various assemblies and provide that to the compiler instead of the real implementation assemblies.

Thoughts?

@benvillalobos
Copy link
Member Author

Don't change that assembly (all assemblies?) away from netstandard2.0

Seems like a reasonable thing to try. All assemblies seems opposed to the whole idea behind the PR though

Build a netstandard2.0 version of the ref assembly for our various assemblies and provide that to the compiler instead of the real implementation assemblies.

Does <PackageDownload> not accomplish this for us? I'm confused about that so I'll brain dump. We added a PackageDownload of netstandard.dll because we needed the ref assemblies. You're suggesting we create a netstandard2.0 ref assembly for Microsoft.Build.Tasks.Core.dll? Is that so different from keeping Microsoft.Build.Tasks.Core.dll with the netstandard2.0 TF?

@rainersigwald
Copy link
Member

All assemblies seems opposed to the whole idea behind the PR though

Yeah, I'm worried we didn't fully understand the implications.

We added a PackageDownload of netstandard.dll because we needed the ref assemblies.

Correct. That gets us the assembly to put in our output package even though it's not referenced for us automatically (because we now autoreference .NET 6 stuff).

You're suggesting we create a netstandard2.0 ref assembly for Microsoft.Build.Tasks.Core.dll? Is that so different from keeping Microsoft.Build.Tasks.Core.dll with the netstandard2.0 TF?

Yeah, it's pretty different. Leaving the reference as netstandard2.0 means we can't make use of any new API surface in .NET Core 2.1+ and may miss out on performance optimizations that could be used with the higher target. Building a new ref assembly means we can't use any new types in our public interface, but means our internal implementations can do whatever we want.

@marcpopMSFT marcpopMSFT modified the milestones: 17.0, MSBuild 17.1 Jul 9, 2021
@marcpopMSFT marcpopMSFT modified the milestones: MSBuild 17.1, .NET 7 Sep 10, 2021
@benvillalobos
Copy link
Member Author

Latest internal build 🤞🤞🤞🤞🤞🤞

https://dev.azure.com/devdiv/DevDiv/_build/results?buildId=5745444&view=results

This should fix the issue upstream where ns2.0 ref assemblies were getting picked up by default because ref/net472 or ref/net6.0 didn't exist.

Old Microsoft.Build.Tasks.Core NuGet package size
With ns2.0 ref assembly: 1.74MB

Old Microsoft.Build.Tasks.Core NuGet package size
With net472 & net6.0 ref assembly: 2.21MB

Copy link
Member

@rainersigwald rainersigwald left a comment

Choose a reason for hiding this comment

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

I'm getting so excited.

@@ -90,9 +94,13 @@
</PropertyGroup>

<!-- Ensure ns2.0 ref assemblies are placed under `ref/netstandard2.0` in the NuGet package -->
Copy link
Member

Choose a reason for hiding this comment

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

Comment stale now :)

<ItemGroup>
<TfmSpecificPackageFile Include="@(BuiltProjectOutputGroupOutput);@(FinalDocFile)">
<TfmSpecificPackageFile Include="@(IntermediateRefAssembly);@(FinalDocFile)">
Copy link
Member

Choose a reason for hiding this comment

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

So I'd say you should use $(TargetRefPath) here; it should be identical for all realistic official build cases but that's the "final" ref assembly location; @(IntermediateRefAssembly) is written to by the compiler every time.

@benvillalobos
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@benvillalobos
Copy link
Member Author

@benvillalobos
Copy link
Member Author

Also works if I reference the generated nuget package locally:

image

@@ -10,7 +10,7 @@
<ItemGroup>
<PackageReference Update="Microsoft.Build.NuGetSdkResolver" Version="$(NuGetBuildTasksVersion)" />
<PackageReference Update="Microsoft.CodeAnalysis.Build.Tasks" Version="$(MicrosoftNetCompilersToolsetVersion)" />
<PackageReference Update="Microsoft.CodeAnalysis.Collections" Version="4.0.0-4.21379.20" />
<PackageReference Update="Microsoft.CodeAnalysis.Collections" Version="4.2.0-1.22102.8" />
Copy link
Member

Choose a reason for hiding this comment

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

Do you have any exp/ insertions where you ran RPS? It'd also be nice if you could see why the optional test failed or find a known bug; lots of MSBuild-caused issues don't directly seem to mention MSBuild.

This change in particular sounds like it could cause version mismatches.

Copy link
Member Author

Choose a reason for hiding this comment

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

I could've sworn I ran RPS on https://dev.azure.com/devdiv/DevDiv/_git/VS/pullrequest/380160. I'll retrigger on that PR.

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 full suite of tests should be queued: https://dev.azure.com/devdiv/DevDiv/_git/VS/pullrequest/380160

<LibraryTargetFrameworks Condition="'$(MonoBuild)'=='true'">$(FullFrameworkTFM)</LibraryTargetFrameworks>
<LibraryTargetFrameworks>$(FullFrameworkTFM);net6.0;netstandard2.0</LibraryTargetFrameworks>
<LibraryTargetFrameworks Condition="'$(DotNetBuildFromSource)' == 'true'">net6.0;netstandard2.0</LibraryTargetFrameworks>
<LibraryTargetFrameworks Condition="'$(MonoBuild)'=='true'">$(FullFrameworkTFM);netstandard2.0</LibraryTargetFrameworks>
Copy link
Member

Choose a reason for hiding this comment

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

Do we still care about this?

Copy link
Member Author

Choose a reason for hiding this comment

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

About the monobuild case adding ns2.0? I added it to be safe because of how we're shipping ns2.0 ref assemblies now.

<Target Name="ShipRefAssembliesToNuGetPackage" BeforeTargets="Pack" Condition="$(IsInnerBuild) == true">
<ItemGroup>
<TfmSpecificPackageFile Include="$(TargetRefPath);@(FinalDocFile)">
<PackagePath>ref/$(TargetFramework)</PackagePath>
Copy link
Member

Choose a reason for hiding this comment

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

nit:

Suggested change
<PackagePath>ref/$(TargetFramework)</PackagePath>
<PackagePath>ref\$(TargetFramework)</PackagePath>

</TfmSpecificPackageFile>
<!-- ns2.0 builds use `BuiltProjectOutputGroupOutput` for output ref assemblies -->
<TfmSpecificPackageFile Include="@(BuiltProjectOutputGroupOutput)" Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackagePath>ref/$(TargetFramework)</PackagePath>
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
<PackagePath>ref/$(TargetFramework)</PackagePath>
<PackagePath>ref\$(TargetFramework)</PackagePath>

</PropertyGroup>

<!-- Ensure ref assemblies are placed under `ref/$(TargetFramework)` in the NuGet package -->
<Target Name="ShipRefAssembliesToNuGetPackage" BeforeTargets="Pack" Condition="$(IsInnerBuild) == true">
Copy link
Member

Choose a reason for hiding this comment

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

How is TfmSpecificPackageFile consumed?

Copy link
Member Author

Choose a reason for hiding this comment

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

if (actualException is IOException)
#if RUNTIME_TYPE_NETCORE
// net5.0 included StatusCode in the HttpRequestException.
switch (httpRequestException.StatusCode)
Copy link
Member

Choose a reason for hiding this comment

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

You should be able to put the status code in a variable and have less duplicated code.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't feel strongly enough about this one

@@ -386,7 +386,7 @@ private bool BuildResolvedSettings(ApplicationManifest manifest)
}
else if (String.IsNullOrEmpty(manifest.Publisher))
{
string org = Util.GetRegisteredOrganization();
string org = NativeMethodsShared.IsWindows ? Util.GetRegisteredOrganization() : string.Empty;
Copy link
Member

Choose a reason for hiding this comment

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

Bump rainersigwald's suggestion

@@ -39,7 +39,7 @@ public sealed class GenerateLauncher : TaskExtension

public override bool Execute()
{
if (LauncherPath == null)
if (LauncherPath == null && NativeMethodsShared.IsWindows)
Copy link
Member

Choose a reason for hiding this comment

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

Is this meant as a "don't run on windows"? Attribute to disable it would be much better here or making it more effectively crash.

Copy link
Member Author

Choose a reason for hiding this comment

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

Somehow I skipped over this one. It's part of clickonce, so I'll mark the class as windows only and log "NotSupported" if Execute is called and we're not on windows.

@@ -143,15 +139,15 @@ private static PermissionSet GetNamedPermissionSetFromZone(string targetZone, st

private static PermissionSet GetNamedPermissionSet(string targetZone, string targetFrameworkMoniker)
{
FrameworkNameVersioning fn;
FrameworkName fn;
Copy link
Member

Choose a reason for hiding this comment

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

nit: ternary initializer --> saves 7 lines here, for instance.

@@ -495,6 +491,7 @@ public static PermissionSet XmlToPermissionSet(XmlElement element)
/// <param name="certThumbprint">Hexadecimal string that contains the SHA-1 hash of the certificate.</param>
/// <param name="timestampUrl">URL that specifies an address of a time stamping server.</param>
/// <param name="path">Path of the file to sign with the certificate.</param>
[SupportedOSPlatform("windows")]
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 just be applied to the class?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think so in this case. There are lots of internal static methods here that are valid cross-OS.

Copy link
Member

@rainersigwald rainersigwald left a comment

Choose a reason for hiding this comment

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

Small nits remain.

src/Framework/README.md Outdated Show resolved Hide resolved
@@ -15,7 +15,7 @@
an imported package. This suppression should be removed if/when the project is migrated to enable nullable
reference types.
-->
<NoWarn>$(NoWarn),CS8632</NoWarn>
<NoWarn>$(NoWarn);CS8632</NoWarn>
Copy link
Member

Choose a reason for hiding this comment

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

Sorry to merge conflict but since you pointed this out: #7426.

Copy link
Member Author

Choose a reason for hiding this comment

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

I undid this change so prevent a merge conflict.

Copy link
Member Author

@benvillalobos benvillalobos left a comment

Choose a reason for hiding this comment

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

Responding to final comments. Kicked DDRITs on my draft VS PR here: https://dev.azure.com/devdiv/DevDiv/_git/VS/pullrequest/380160

@@ -10,7 +10,7 @@
<ItemGroup>
<PackageReference Update="Microsoft.Build.NuGetSdkResolver" Version="$(NuGetBuildTasksVersion)" />
<PackageReference Update="Microsoft.CodeAnalysis.Build.Tasks" Version="$(MicrosoftNetCompilersToolsetVersion)" />
<PackageReference Update="Microsoft.CodeAnalysis.Collections" Version="4.0.0-4.21379.20" />
<PackageReference Update="Microsoft.CodeAnalysis.Collections" Version="4.2.0-1.22102.8" />
Copy link
Member Author

Choose a reason for hiding this comment

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

I could've sworn I ran RPS on https://dev.azure.com/devdiv/DevDiv/_git/VS/pullrequest/380160. I'll retrigger on that PR.

<LibraryTargetFrameworks Condition="'$(MonoBuild)'=='true'">$(FullFrameworkTFM)</LibraryTargetFrameworks>
<LibraryTargetFrameworks>$(FullFrameworkTFM);net6.0;netstandard2.0</LibraryTargetFrameworks>
<LibraryTargetFrameworks Condition="'$(DotNetBuildFromSource)' == 'true'">net6.0;netstandard2.0</LibraryTargetFrameworks>
<LibraryTargetFrameworks Condition="'$(MonoBuild)'=='true'">$(FullFrameworkTFM);netstandard2.0</LibraryTargetFrameworks>
Copy link
Member Author

Choose a reason for hiding this comment

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

About the monobuild case adding ns2.0? I added it to be safe because of how we're shipping ns2.0 ref assemblies now.

</PropertyGroup>

<!-- Ensure ref assemblies are placed under `ref/$(TargetFramework)` in the NuGet package -->
<Target Name="ShipRefAssembliesToNuGetPackage" BeforeTargets="Pack" Condition="$(IsInnerBuild) == true">
Copy link
Member Author

Choose a reason for hiding this comment

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

/// <summary>
/// Gets a flag indicating if we are running under some version of Windows
/// </summary>
[SupportedOSPlatformGuard("windows")]
Copy link
Member Author

Choose a reason for hiding this comment

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

No it's still allowed, it prevents the compiler from complaining about windows only code paths. Basically, IsWindows itself is treated as a [SupportedOSPlatform("windows")]

@@ -36,7 +36,7 @@ public SdkResultItem(string itemSpec, Dictionary<string, string>? metadata)
Metadata = metadata;
}

public override bool Equals(object obj)
public override bool Equals(object? obj)
Copy link
Member Author

Choose a reason for hiding this comment

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

Created an issue for this: #7427

if (actualException is IOException)
#if RUNTIME_TYPE_NETCORE
// net5.0 included StatusCode in the HttpRequestException.
switch (httpRequestException.StatusCode)
Copy link
Member Author

Choose a reason for hiding this comment

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

I don't feel strongly enough about this one

@@ -386,7 +386,7 @@ private bool BuildResolvedSettings(ApplicationManifest manifest)
}
else if (String.IsNullOrEmpty(manifest.Publisher))
{
string org = Util.GetRegisteredOrganization();
string org = NativeMethodsShared.IsWindows ? Util.GetRegisteredOrganization() : string.Empty;
Copy link
Member Author

Choose a reason for hiding this comment

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

Blarg, I had a pending comment here I didn't publish. I'm sold on the idea of applying it to the whole class and erroring in the Execute method.

Comment on lines 10 to 13
using System.Runtime.Versioning;
#if RUNTIME_TYPE_NETCORE
using System.Runtime.InteropServices.ComTypes;
#endif
Copy link
Member Author

Choose a reason for hiding this comment

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

My brain says yes, my heart says no 😄

@@ -495,6 +491,7 @@ public static PermissionSet XmlToPermissionSet(XmlElement element)
/// <param name="certThumbprint">Hexadecimal string that contains the SHA-1 hash of the certificate.</param>
/// <param name="timestampUrl">URL that specifies an address of a time stamping server.</param>
/// <param name="path">Path of the file to sign with the certificate.</param>
[SupportedOSPlatform("windows")]
Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think so in this case. There are lots of internal static methods here that are valid cross-OS.

@@ -10,7 +10,7 @@
<ItemGroup>
<PackageReference Update="Microsoft.Build.NuGetSdkResolver" Version="$(NuGetBuildTasksVersion)" />
<PackageReference Update="Microsoft.CodeAnalysis.Build.Tasks" Version="$(MicrosoftNetCompilersToolsetVersion)" />
<PackageReference Update="Microsoft.CodeAnalysis.Collections" Version="4.0.0-4.21379.20" />
<PackageReference Update="Microsoft.CodeAnalysis.Collections" Version="4.2.0-1.22102.8" />
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 full suite of tests should be queued: https://dev.azure.com/devdiv/DevDiv/_git/VS/pullrequest/380160

Copy link
Member

@Forgind Forgind left a comment

Choose a reason for hiding this comment

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

Pending successful exp/ insertion (green build/tests/RPS)

https://dev.azure.com/devdiv/DevDiv/_git/VS/pullrequest/380160

@benvillalobos
Copy link
Member Author

All green: https://devdiv.visualstudio.com/DevDiv/_git/VS/pullrequest/383388

@benvillalobos benvillalobos added the merge-when-branch-open PRs that are approved, except that there is a problem that means we are not merging stuff right now. label Mar 7, 2022
@benvillalobos benvillalobos changed the title Update projects targeting netstandard2.0 MSBuild Upgrade: netstandard2.0 -> net6.0 Mar 7, 2022
@benvillalobos benvillalobos merged commit 9c17329 into dotnet:main Mar 7, 2022
@benvillalobos benvillalobos deleted the netstandard2.0-to-net5.0 branch March 7, 2022 19:19
benvillalobos added a commit to benvillalobos/msbuild that referenced this pull request Mar 11, 2022
@@ -273,7 +274,7 @@ private void init()
Sha256SignatureMethodUri);

#if RUNTIME_TYPE_NETCORE
CryptoConfig.AddAlgorithm(typeof(SHA256Managed),
CryptoConfig.AddAlgorithm(typeof(SHA256),
Copy link
Member

Choose a reason for hiding this comment

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

@benvillalobos do you remember why it was needed to switch from SHA256Managed?
We have a bug now, I am thinking about getting back to SHA256Managed

#9248

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge-when-branch-open PRs that are approved, except that there is a problem that means we are not merging stuff right now.
Projects
No open projects
17.0
In progress
Development

Successfully merging this pull request may close these issues.

Update Projects Targeting netstandard2.0
8 participants