-
Notifications
You must be signed in to change notification settings - Fork 1.4k
MSBuild Upgrade: netstandard2.0 -> net6.0 #6148
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
Changes from all commits
f17f607
b1ac2ab
c5ae661
b2fa123
d98fe68
3326faf
642093a
d5370bf
f6c1204
6f0581f
c720814
499f6dc
98b28d1
a34b2fa
36cff17
982d5bc
8e89508
ab5b02a
8cb9f2c
18b8d7c
65212a4
e9bed31
9863e76
c927db5
27a0b10
42f8e51
28f0894
7e07f74
72bf1ac
6a262ef
987fd62
ce53557
b388739
44626b8
6099f12
5f3e506
6a0fa83
c9362f3
aede573
cf57afb
63b0b39
2a8ce53
f253f5a
ffb3d6b
a47d737
ca7b487
ecfff47
7b90a53
0549c14
34a8b6d
0bcaf19
2b00f97
21a1975
f47d739
7e50fa8
8771062
4c7ff53
990538c
84a11ad
7ef24b2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,9 @@ | |
| <!-- Ensure that compiler errors emit full paths so that files | ||
| can be correctly annotated in GitHub. --> | ||
| <GenerateFullPaths>true</GenerateFullPaths> | ||
|
|
||
| <!-- https://github.com/NuGet/Home/issues/8684 --> | ||
| <NoWarn>$(NoWarn);NU5131</NoWarn> | ||
|
|
||
| <!-- Do not mangle paths for test assemblies, because Shoudly assertions want actual on-disk paths. --> | ||
| <DeterministicSourcePaths Condition="'$(IsTestProject)' == 'true'">false</DeterministicSourcePaths> | ||
|
|
@@ -27,8 +30,9 @@ | |
| <Platforms>AnyCPU;x64</Platforms> | ||
|
|
||
| <!-- Defaults for target frameworks and architecture --> | ||
| <LibraryTargetFrameworks>$(FullFrameworkTFM);netstandard2.0</LibraryTargetFrameworks> | ||
| <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> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we still care about this?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| <PlatformTarget>AnyCPU</PlatformTarget> | ||
|
|
||
| <!-- Target frameworks for Exe and unit test projects (ie projects with runtime output) --> | ||
|
|
@@ -71,4 +75,34 @@ | |
| <!-- When targeting .NET Core, Exe and unit tests projects always use AnyCPU architecture --> | ||
| <RuntimeOutputPlatformTarget>AnyCPU</RuntimeOutputPlatformTarget> | ||
| </PropertyGroup> | ||
|
|
||
| <PropertyGroup> | ||
| <TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificContentInPackage);ShipRefAssembliesToNuGetPackage</TargetsForTfmSpecificBuildOutput> | ||
| </PropertyGroup> | ||
|
|
||
| <!-- Produce ONLY reference assemblies and SKIP roslyn analyzers for netstandard2.0 builds. --> | ||
| <PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.0' and '$(MSBuildProjectFile)' != 'PortableTask.csproj'"> | ||
| <!-- ProduceOnlyReferenceAssembly and ProduceReferenceAssembly are mutually exclusive compiler flags. --> | ||
| <ProduceOnlyReferenceAssembly>true</ProduceOnlyReferenceAssembly> | ||
| <ProduceReferenceAssembly>false</ProduceReferenceAssembly> | ||
Forgind marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| <RunAnalyzers>false</RunAnalyzers> | ||
benvillalobos marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| <TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificContentInPackage);ShipRefAssembliesToNuGetPackage</TargetsForTfmSpecificBuildOutput> | ||
| <IncludeBuildOutput>false</IncludeBuildOutput> | ||
| <!-- pdb publishing fails builds for reference-only assemblies. --> | ||
| <!-- https://github.com/dotnet/msbuild/pull/6148. --> | ||
| <PublishWindowsPdb>false</PublishWindowsPdb> | ||
| </PropertyGroup> | ||
|
|
||
| <!-- Ensure ref assemblies are placed under `ref/$(TargetFramework)` in the NuGet package --> | ||
| <Target Name="ShipRefAssembliesToNuGetPackage" BeforeTargets="Pack" Condition="$(IsInnerBuild) == true"> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How is TfmSpecificPackageFile consumed?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a nuget concept for packaging: https://docs.microsoft.com/en-us/nuget/reference/msbuild-targets#targetsfortfmspecificcontentinpackage |
||
| <ItemGroup> | ||
| <TfmSpecificPackageFile Include="$(TargetRefPath);@(FinalDocFile)"> | ||
| <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> | ||
| </TfmSpecificPackageFile> | ||
| </ItemGroup> | ||
| </Target> | ||
| </Project> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ | |
| using System.IO; | ||
| using System.Reflection; | ||
| using System.Runtime.InteropServices; | ||
| using System.Runtime.Versioning; | ||
| using System.Text; | ||
| using System.Threading; | ||
|
|
||
|
|
@@ -21,9 +22,10 @@ | |
| #nullable disable | ||
|
|
||
| namespace Microsoft.Build.Framework; | ||
|
|
||
| internal static class NativeMethods | ||
| { | ||
| #region Constants | ||
| #region Constants | ||
|
|
||
| internal const uint ERROR_INSUFFICIENT_BUFFER = 0x8007007A; | ||
| internal const uint STARTUP_LOADER_SAFEMODE = 0x10; | ||
|
|
@@ -71,9 +73,9 @@ internal static class NativeMethods | |
| internal const uint WAIT_OBJECT_0 = 0x00000000; | ||
| internal const uint WAIT_TIMEOUT = 0x00000102; | ||
|
|
||
| #endregion | ||
| #endregion | ||
|
|
||
| #region Enums | ||
| #region Enums | ||
|
|
||
| private enum PROCESSINFOCLASS : int | ||
| { | ||
|
|
@@ -198,9 +200,9 @@ internal enum ProcessorArchitectures | |
| Unknown | ||
| } | ||
|
|
||
| #endregion | ||
| #endregion | ||
|
|
||
| #region Structs | ||
| #region Structs | ||
|
|
||
| /// <summary> | ||
| /// Structure that contain information about the system on which we are running | ||
|
|
@@ -568,9 +570,9 @@ private unsafe static int GetLogicalCoreCountOnWindows() | |
| return -1; | ||
| } | ||
|
|
||
| #endregion | ||
| #endregion | ||
|
|
||
| #region Member data | ||
| #region Member data | ||
|
|
||
| internal static bool HasMaxPath => MaxPath == MAX_PATH; | ||
|
|
||
|
|
@@ -709,10 +711,10 @@ internal static bool IsMono | |
| #if !CLR2COMPATIBILITY | ||
| private static bool? _isWindows; | ||
| #endif | ||
|
|
||
| /// <summary> | ||
| /// Gets a flag indicating if we are running under some version of Windows | ||
| /// </summary> | ||
| [SupportedOSPlatformGuard("windows")] | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think you can do this? Doesn't this mean that platforms other than windows can't check if they're windows or not?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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, |
||
| internal static bool IsWindows | ||
| { | ||
| #if CLR2COMPATIBILITY | ||
|
|
@@ -867,9 +869,9 @@ private static SystemInformationData SystemInformation | |
| /// </summary> | ||
| internal static ProcessorArchitectures ProcessorArchitectureNative => SystemInformation.ProcessorArchitectureTypeNative; | ||
|
|
||
| #endregion | ||
| #endregion | ||
|
|
||
| #region Wrapper methods | ||
| #region Wrapper methods | ||
|
|
||
| /// <summary> | ||
| /// Really truly non pumping wait. | ||
|
|
@@ -1451,9 +1453,9 @@ internal static void VerifyThrowWin32Result(int result) | |
| } | ||
| } | ||
|
|
||
| #endregion | ||
| #endregion | ||
|
|
||
| #region PInvoke | ||
| #region PInvoke | ||
|
|
||
| /// <summary> | ||
| /// Gets the current OEM code page which is used by console apps | ||
|
|
@@ -1609,9 +1611,9 @@ out FILETIME lpLastWriteTime | |
| [DllImport("kernel32.dll", SetLastError = true)] | ||
| internal static extern bool SetThreadErrorMode(int newMode, out int oldMode); | ||
|
|
||
| #endregion | ||
| #endregion | ||
|
|
||
| #region Extensions | ||
| #region Extensions | ||
|
|
||
| /// <summary> | ||
| /// Waits while pumping APC messages. This is important if the waiting thread is an STA thread which is potentially | ||
|
|
@@ -1654,9 +1656,9 @@ internal static bool MsgWaitOne(this WaitHandle handle, int timeout) | |
| return returnValue == 0; | ||
| } | ||
|
|
||
| #endregion | ||
| #endregion | ||
|
|
||
| #region helper methods | ||
| #region helper methods | ||
|
|
||
| internal static bool DirectoryExists(string fullPath) | ||
| { | ||
|
|
@@ -1699,6 +1701,6 @@ internal static bool FileOrDirectoryExistsWindows(string path) | |
| return GetFileAttributesEx(path, 0, ref data); | ||
| } | ||
|
|
||
| #endregion | ||
| #endregion | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just because you touched it... Should the equality check not be case insensitive?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bump
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Created an issue for this: #7427 |
||
| { | ||
| if (obj is SdkResultItem item && | ||
| ItemSpec == item.ItemSpec && | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| // Copyright (c) Microsoft. All rights reserved. | ||
| // Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
|
||
| #if !NET6_0_OR_GREATER | ||
| namespace System.Runtime.Versioning | ||
| { | ||
| /// <summary> | ||
| /// SupportedOSPlatform is a net5.0+ Attribute. | ||
| /// Create the same type only in full-framework and netstandard2.0 builds | ||
| /// to prevent many #if RUNTIME_TYPE_NETCORE checks. | ||
| /// </summary> | ||
| [AttributeUsage(AttributeTargets.Method | AttributeTargets.Property)] | ||
| internal class SupportedOSPlatformGuard : Attribute | ||
| { | ||
| internal SupportedOSPlatformGuard(string platformName) | ||
| { | ||
| } | ||
| } | ||
| [AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Class)] | ||
| internal class SupportedOSPlatform : Attribute | ||
| { | ||
| internal SupportedOSPlatform(string platformName) | ||
| { | ||
| } | ||
| } | ||
| } | ||
| #endif |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,7 +14,6 @@ | |
| using SystemProcessorArchitecture = System.Reflection.ProcessorArchitecture; | ||
| using Xunit.Abstractions; | ||
| using Shouldly; | ||
| using System.Text; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
|
|
||
| #nullable disable | ||
|
|
||
|
|
||
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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