Skip to content

Commit

Permalink
Target netcoreapp3.0
Browse files Browse the repository at this point in the history
The only critical change here is to handle double parsing to infinity: it
changed behavior in .NET Core 3.0 (rounding to infinity instead of
failing to parse) so I preserved the original behavior in MSBuild since
math around infinity doesn't seem like a reasonable MSBuild use case.
  • Loading branch information
rainersigwald committed Nov 14, 2019
1 parent f2a49ed commit c3fc53d
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ Set the environment variable `MSBUILDDEBUGONSTART` to `2`, then attach a debugge

To build projects using the MSBuild binaries from the repository, you first need to do a build (command: `build.cmd /p:CreateBootstrap=true`) which produces a bootstrap directory mimicking a Visual Studio (full framework flavor) or dotnet CLI (.net core flavor) installation.

Now, just point `dotnet ./artifacts/bin/bootstrap/netcoreapp2.1/MSBuild/MSBuild.dll` at a project file.
Now, just point `dotnet ./artifacts/bin/bootstrap/netcoreapp3.0/MSBuild/MSBuild.dll` at a project file.

Alternatively, if you want to test the msbuild binaries in a more realistic environment, you can overwrite the dotnet CLI msbuild binaries (found under a path like `~/dotnet/sdk/3.0.100-alpha1-009428/`) with the msbuild binaries from the above bootstrap directory. You might have to kill existing `dotnet` processes before doing this. Then, (using the previous dotnet example directory) just point `~/dotnet/dotnet build` at a project file.
2 changes: 1 addition & 1 deletion eng/cibuild_bootstrapped_msbuild.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ try {
else
{
$buildToolPath = $dotnetExePath
$buildToolCommand = Join-Path $bootstrapRoot "netcoreapp2.1\MSBuild\MSBuild.dll"
$buildToolCommand = Join-Path $bootstrapRoot "netcoreapp3.0\MSBuild\MSBuild.dll"
}

# Use separate artifacts folder for stage 2
Expand Down
4 changes: 3 additions & 1 deletion eng/cibuild_bootstrapped_msbuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ then
InitializeDotNetCli true

_InitializeBuildTool="$_InitializeDotNetCli/dotnet"
_InitializeBuildToolCommand="$bootstrapRoot/netcoreapp2.1/MSBuild/MSBuild.dll"
_InitializeBuildToolCommand="$bootstrapRoot/netcoreapp3.0/MSBuild/MSBuild.dll"
# Note: this isn't MSBuild's runtime, it must match the runtime of the
# Arcade logger
_InitializeBuildToolFramework="netcoreapp2.1"
else
echo "Unsupported hostType ($host_type)"
Expand Down
5 changes: 0 additions & 5 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
{
"tools": {
"dotnet": "3.0.100",
"runtimes": {
"dotnet/x64": [
"2.1.7"
]
},
"vs": {
"version": "16.0"
}
Expand Down
9 changes: 4 additions & 5 deletions src/Build/Microsoft.Build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
<Import Project="..\Shared\DebuggingSources.proj" />

<PropertyGroup>
<!-- Node reuse requires an API new to .NET Core 2.1 not yet available
in .NETStandard. -->
<TargetFrameworks>netcoreapp2.1</TargetFrameworks>
<TargetFrameworks Condition="'$(OsEnvironment)'=='windows'">$(FullFrameworkTFM);netcoreapp2.1</TargetFrameworks>
<!-- Some features use Core APIs that won't be in .NET Standard, so target Core directly. -->
<TargetFrameworks>netcoreapp3.0</TargetFrameworks>
<TargetFrameworks Condition="'$(OsEnvironment)'=='windows'">$(FullFrameworkTFM);netcoreapp3.0</TargetFrameworks>
<TargetFrameworks Condition="'$(MonoBuild)'=='true'">$(RuntimeOutputTargetFrameworks)</TargetFrameworks>
<RootNamespace>Microsoft.Build</RootNamespace>
<AssemblyName>Microsoft.Build</AssemblyName>
Expand Down Expand Up @@ -49,7 +48,7 @@
<PackageReference Include="System.Reflection.Metadata" />
<PackageReference Include="System.Reflection.TypeExtensions" />
<PackageReference Include="System.Runtime.Loader" />
<PackageReference Include="System.Security.Principal.Windows" Condition="'$(TargetFramework)' == 'netcoreapp2.1'" />
<PackageReference Include="System.Security.Principal.Windows" Condition="'$(TargetFramework)' == 'netcoreapp3.0'" />
<PackageReference Include="System.Text.Encoding.CodePages" />
<!-- Need Win32 API on .NET Core to ping registry to determine long path support -->
<PackageReference Include="Microsoft.Win32.Registry" />
Expand Down
2 changes: 1 addition & 1 deletion src/Directory.BeforeCommon.targets
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
<DefineConstants>$(DefineConstants);WORKAROUND_COREFX_19110</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'netcoreapp2.1'">
<PropertyGroup Condition="'$(TargetFramework)' == 'netcoreapp3.0'">
<DefineConstants>$(DefineConstants);FEATURE_PIPEOPTIONS_CURRENTUSERONLY</DefineConstants>
<DefineConstants Condition="'$(MachineIndependentBuild)' != 'true'">$(DefineConstants);FEATURE_NODE_REUSE</DefineConstants>
<DefineConstants>$(DefineConstants);FEATURE_SPAN</DefineConstants>
Expand Down
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<PlatformTarget>AnyCPU</PlatformTarget>

<!-- Target frameworks for Exe and unit test projects (ie projects with runtime output) -->
<RuntimeOutputTargetFrameworks>netcoreapp2.1</RuntimeOutputTargetFrameworks>
<RuntimeOutputTargetFrameworks>netcoreapp3.0</RuntimeOutputTargetFrameworks>
<RuntimeOutputTargetFrameworks Condition="'$(OsEnvironment)'=='windows' and '$(DotNetBuildFromSource)' != 'true'">$(FullFrameworkTFM);$(RuntimeOutputTargetFrameworks)</RuntimeOutputTargetFrameworks>
<RuntimeOutputTargetFrameworks Condition="'$(MonoBuild)' == 'true'">net461</RuntimeOutputTargetFrameworks>

Expand Down
4 changes: 2 additions & 2 deletions src/MSBuild.Bootstrap/MSBuild.Bootstrap.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@
</ItemGroup>

<!-- Use deps file from this project with additional dependencies listed instead of the one generated in the MSBuild project -->
<Target Name="UpdateMSBuildDepsFile" AfterTargets="Build" Condition="'$(TargetFramework)' == 'netcoreapp2.1' or '$(TargetFramework)' == 'netstandard2.0'">
<Target Name="UpdateMSBuildDepsFile" AfterTargets="Build" Condition="'$(TargetFramework)' == 'netcoreapp3.0' or '$(TargetFramework)' == 'netstandard2.0'">
<Copy SourceFiles="$(OutputPath)$(AssemblyName).deps.json" DestinationFiles="$(OutputPath)MSBuild.deps.json" />
</Target>
<Target Name="UpdatePublishedMSBuildDepsFile" AfterTargets="Publish" Condition="'$(TargetFramework)' == 'netcoreapp2.1'">
<Target Name="UpdatePublishedMSBuildDepsFile" AfterTargets="Publish" Condition="'$(TargetFramework)' == 'netcoreapp3.0'">
<Copy SourceFiles="$(PublishDir)$(AssemblyName).deps.json" DestinationFiles="$(PublishDir)MSBuild.deps.json" />
</Target>

Expand Down
3 changes: 3 additions & 0 deletions src/MSBuild/MSBuild.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
versions of this project -->
<RuntimeIdentifiers>win7-x86;win7-x64</RuntimeIdentifiers>

<!-- Don't produce the .exe, because the CLI directly invokes the DLL and so should tests -->
<UseAppHost>false</UseAppHost>

<EnableDefaultItems>false</EnableDefaultItems>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<AssemblyName>MSBuild</AssemblyName>
Expand Down
2 changes: 1 addition & 1 deletion src/Package/Localization/Localization.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework Condition="$(MonoBuild) != 'true'">netcoreapp2.1</TargetFramework>
<TargetFramework Condition="$(MonoBuild) != 'true'">netcoreapp3.0</TargetFramework>
<TargetFramework Condition="$(MonoBuild) == 'true'">net461</TargetFramework>
<NuspecFile>Microsoft.Build.Localization.nuspec</NuspecFile>
<IsShipping>false</IsShipping>
Expand Down
7 changes: 6 additions & 1 deletion src/Shared/ConversionUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,12 @@ private static bool ValidHexNumber(string number)
private static bool ValidDecimalNumber(string number)
{
double value;
return Double.TryParse(number, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, CultureInfo.InvariantCulture.NumberFormat, out value);
return Double.TryParse(number, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, CultureInfo.InvariantCulture.NumberFormat, out value)
// CoreCLR 3.0+ correctly rounds unrepresentably large numbers to infinity,
// but desktop and prior versions do not; match the old behavior since users
// are unlikely to want to deal with floating-point infinity calculations in
// the context of MSBuild.
&& !double.IsInfinity(value);
}

/// <summary>
Expand Down

0 comments on commit c3fc53d

Please sign in to comment.