Skip to content

Commit 75206ed

Browse files
authored
Make Microsoft.NETCore.Platforms pack from CSProj (#50468)
* Use CSProj for packing Platforms package * Port GenerateRuntimeGraph task This ports the GenerateRuntimeGraph task from arcade as of https://github.com/dotnet/arcade/tree/d005a8ce6bb81129f9c3a4a907e1b7ccbf2504d5 * Refactor GenerateRuntimeGraph into separate files * Add test for GenerateRuntimeGraph * Fix up path to runtime.json * Don't filter inner builds when building Platforms task * Skip tests RuntimeGraph task tests on some platforms * Exclude browser from testing instead of wasm * Another try at suppressing testing on Browser
1 parent 5ff4d6d commit 75206ed

24 files changed

Lines changed: 1324 additions & 32 deletions

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@
228228
<RepositoryUrl>https://github.com/dotnet/$(GitHubRepositoryName)</RepositoryUrl>
229229
<PackageProjectUrl>https://dot.net</PackageProjectUrl>
230230
<Owners>microsoft,dotnetframework</Owners>
231-
<RuntimeIdGraphDefinitionFile>$([MSBuild]::NormalizePath('$(LibrariesProjectRoot)', 'Microsoft.NETCore.Platforms', 'pkg', 'runtime.json'))</RuntimeIdGraphDefinitionFile>
231+
<RuntimeIdGraphDefinitionFile>$([MSBuild]::NormalizePath('$(LibrariesProjectRoot)', 'Microsoft.NETCore.Platforms', 'src', 'runtime.json'))</RuntimeIdGraphDefinitionFile>
232232
<LicenseFile>$(MSBuildThisFileDirectory)LICENSE.TXT</LicenseFile>
233233
<PackageLicenseExpression>MIT</PackageLicenseExpression>
234234
<Copyright>$(CopyrightNetFoundation)</Copyright>

eng/Versions.props

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,12 @@
139139
These are used as reference assemblies only, so they must not take a ProdCon/source-build
140140
version. Insert "RefOnly" to avoid assignment via PVP.
141141
-->
142-
<RefOnlyMicrosoftBuildVersion>15.7.179</RefOnlyMicrosoftBuildVersion>
142+
<RefOnlyMicrosoftBuildVersion>16.8.0</RefOnlyMicrosoftBuildVersion>
143143
<RefOnlyMicrosoftBuildFrameworkVersion>$(RefOnlyMicrosoftBuildVersion)</RefOnlyMicrosoftBuildFrameworkVersion>
144144
<RefOnlyMicrosoftBuildTasksCoreVersion>$(RefOnlyMicrosoftBuildVersion)</RefOnlyMicrosoftBuildTasksCoreVersion>
145145
<RefOnlyMicrosoftBuildUtilitiesCoreVersion>$(RefOnlyMicrosoftBuildVersion)</RefOnlyMicrosoftBuildUtilitiesCoreVersion>
146-
<RefOnlyNugetProjectModelVersion>4.9.4</RefOnlyNugetProjectModelVersion>
147-
<RefOnlyNugetPackagingVersion>4.9.4</RefOnlyNugetPackagingVersion>
146+
<RefOnlyNugetProjectModelVersion>5.8.0</RefOnlyNugetProjectModelVersion>
147+
<RefOnlyNugetPackagingVersion>5.8.0</RefOnlyNugetPackagingVersion>
148148
<!-- Testing -->
149149
<MicrosoftNETCoreCoreDisToolsVersion>1.0.1-prerelease-00006</MicrosoftNETCoreCoreDisToolsVersion>
150150
<MicrosoftNETTestSdkVersion>16.9.0-preview-20201201-01</MicrosoftNETTestSdkVersion>

src/libraries/Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<GeneratePlatformNotSupportedAssemblyHeaderFile>$(RepositoryEngineeringDir)LicenseHeader.txt</GeneratePlatformNotSupportedAssemblyHeaderFile>
2222
</PropertyGroup>
2323

24-
<Import Sdk="Microsoft.DotNet.Build.Tasks.TargetFramework.Sdk" Project="Sdk.props" />
24+
<Import Sdk="Microsoft.DotNet.Build.Tasks.TargetFramework.Sdk" Project="Sdk.props" Condition="'$(UseTargetFrameworkSDK)' != 'false'" />
2525

2626
<PropertyGroup>
2727
<BuildTargetFramework Condition="'$(BuildTargetFramework)' == '' and '$(TargetFramework)' != ''">$([System.Text.RegularExpressions.Regex]::Replace('$(TargetFramework)', '(-[^;]+)', ''))</BuildTargetFramework>

src/libraries/Directory.Build.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116
<Import Project="$(RepositoryEngineeringDir)testing\coverage.targets" Condition="'$(EnableRunSettingsSupport)' == 'true' or '$(EnableCoverageSupport)' == 'true'" />
117117
<Import Project="$(RepositoryEngineeringDir)slngen.targets" />
118118

119-
<Import Sdk="Microsoft.DotNet.Build.Tasks.TargetFramework.Sdk" Project="Sdk.targets" />
119+
<Import Sdk="Microsoft.DotNet.Build.Tasks.TargetFramework.Sdk" Project="Sdk.targets" Condition="'$(UseTargetFrameworkSDK)' != 'false'" />
120120
<Import Project="$(RepositoryEngineeringDir)restore\repoRestore.targets" Condition="'$(DisableProjectRestore)' == 'true'" />
121121
<Import Project="$(RepositoryEngineeringDir)illink.targets" Condition="'$(IsSourceProject)' == 'true'" />
122122
<Import Project="$(RepositoryEngineeringDir)AvoidRestoreCycleOnSelfReference.targets" Condition="'$(AvoidRestoreCycleOnSelfReference)' == 'true'" />
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.31004.24
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.NETCore.Platforms", "src\Microsoft.NETCore.Platforms.csproj", "{BFFF96CC-06AA-4291-9F93-3E77F23DBB11}"
7+
EndProject
8+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.NETCore.Platforms.Tests", "tests\Microsoft.NETCore.Platforms.Tests.csproj", "{0C60F372-5C73-4BFA-9B91-5659C88F9750}"
9+
EndProject
10+
Global
11+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
12+
Debug|Any CPU = Debug|Any CPU
13+
Release|Any CPU = Release|Any CPU
14+
EndGlobalSection
15+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
16+
{BFFF96CC-06AA-4291-9F93-3E77F23DBB11}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17+
{BFFF96CC-06AA-4291-9F93-3E77F23DBB11}.Debug|Any CPU.Build.0 = Debug|Any CPU
18+
{BFFF96CC-06AA-4291-9F93-3E77F23DBB11}.Release|Any CPU.ActiveCfg = Release|Any CPU
19+
{BFFF96CC-06AA-4291-9F93-3E77F23DBB11}.Release|Any CPU.Build.0 = Release|Any CPU
20+
{0C60F372-5C73-4BFA-9B91-5659C88F9750}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21+
{0C60F372-5C73-4BFA-9B91-5659C88F9750}.Debug|Any CPU.Build.0 = Debug|Any CPU
22+
{0C60F372-5C73-4BFA-9B91-5659C88F9750}.Release|Any CPU.ActiveCfg = Release|Any CPU
23+
{0C60F372-5C73-4BFA-9B91-5659C88F9750}.Release|Any CPU.Build.0 = Release|Any CPU
24+
EndGlobalSection
25+
GlobalSection(SolutionProperties) = preSolution
26+
HideSolutionNode = FALSE
27+
EndGlobalSection
28+
GlobalSection(ExtensibilityGlobals) = postSolution
29+
SolutionGuid = {E946A528-C3E7-48EC-AD6D-AE84ED2B11AC}
30+
EndGlobalSection
31+
EndGlobal

src/libraries/Microsoft.NETCore.Platforms/pkg/Microsoft.NETCore.Platforms.pkgproj

Lines changed: 0 additions & 18 deletions
This file was deleted.
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using System;
5+
using System.Diagnostics;
6+
using System.IO;
7+
using System.Reflection;
8+
9+
namespace Microsoft.NETCore.Platforms.BuildTasks
10+
{
11+
/// <summary>
12+
/// Used to enable app-local assembly unification.
13+
/// </summary>
14+
internal static class AssemblyResolver
15+
{
16+
static AssemblyResolver()
17+
{
18+
AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
19+
}
20+
21+
/// <summary>
22+
/// Call to enable the assembly resolver for the current AppDomain.
23+
/// </summary>
24+
public static void Enable()
25+
{
26+
// intentionally empty. This is just meant to ensure the static constructor
27+
// has run.
28+
}
29+
30+
private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
31+
{
32+
// apply any existing policy
33+
AssemblyName referenceName = new AssemblyName(AppDomain.CurrentDomain.ApplyPolicy(args.Name));
34+
35+
string fileName = referenceName.Name + ".dll";
36+
string assemblyPath = null;
37+
string probingPath = null;
38+
Assembly assm = null;
39+
40+
// look next to requesting assembly
41+
assemblyPath = args.RequestingAssembly?.Location;
42+
if (!string.IsNullOrEmpty(assemblyPath))
43+
{
44+
probingPath = Path.Combine(Path.GetDirectoryName(assemblyPath), fileName);
45+
Debug.WriteLine($"Considering {probingPath} based on RequestingAssembly");
46+
if (Probe(probingPath, referenceName.Version, out assm))
47+
{
48+
return assm;
49+
}
50+
}
51+
52+
// look next to the executing assembly
53+
assemblyPath = Assembly.GetExecutingAssembly().Location;
54+
if (!string.IsNullOrEmpty(assemblyPath))
55+
{
56+
probingPath = Path.Combine(Path.GetDirectoryName(assemblyPath), fileName);
57+
58+
Debug.WriteLine($"Considering {probingPath} based on ExecutingAssembly");
59+
if (Probe(probingPath, referenceName.Version, out assm))
60+
{
61+
return assm;
62+
}
63+
}
64+
65+
// look in AppDomain base directory
66+
probingPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, fileName);
67+
Debug.WriteLine($"Considering {probingPath} based on BaseDirectory");
68+
if (Probe(probingPath, referenceName.Version, out assm))
69+
{
70+
return assm;
71+
}
72+
73+
// look in current directory
74+
Debug.WriteLine($"Considering {fileName}");
75+
if (Probe(fileName, referenceName.Version, out assm))
76+
{
77+
return assm;
78+
}
79+
80+
return null;
81+
}
82+
83+
/// <summary>
84+
/// Considers a path to load for satisfying an assembly ref and loads it
85+
/// if the file exists and version is sufficient.
86+
/// </summary>
87+
/// <param name="filePath">Path to consider for load</param>
88+
/// <param name="minimumVersion">Minimum version to consider</param>
89+
/// <param name="assembly">loaded assembly</param>
90+
/// <returns>true if assembly was loaded</returns>
91+
private static bool Probe(string filePath, Version minimumVersion, out Assembly assembly)
92+
{
93+
if (File.Exists(filePath))
94+
{
95+
AssemblyName name = AssemblyName.GetAssemblyName(filePath);
96+
97+
if (name.Version >= minimumVersion)
98+
{
99+
assembly = Assembly.Load(name);
100+
return true;
101+
}
102+
}
103+
104+
assembly = null;
105+
return false;
106+
}
107+
}
108+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
namespace Microsoft.NETCore.Platforms.BuildTasks
5+
{
6+
public partial class BuildTask
7+
{
8+
static BuildTask()
9+
{
10+
AssemblyResolver.Enable();
11+
}
12+
}
13+
}
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using Microsoft.Build.Framework;
5+
using Microsoft.Build.Utilities;
6+
using System;
7+
8+
namespace Microsoft.NETCore.Platforms.BuildTasks
9+
{
10+
public abstract partial class BuildTask : ITask
11+
{
12+
private Log _log;
13+
14+
internal Log Log
15+
{
16+
get { return _log ?? (_log = new Log(new TaskLoggingHelper(this))); }
17+
}
18+
19+
public BuildTask()
20+
{
21+
}
22+
23+
public IBuildEngine BuildEngine
24+
{
25+
get;
26+
set;
27+
}
28+
29+
public ITaskHost HostObject
30+
{
31+
get;
32+
set;
33+
}
34+
35+
public abstract bool Execute();
36+
}
37+
38+
internal class Log : ILog
39+
{
40+
private readonly TaskLoggingHelper _logger;
41+
public Log(TaskLoggingHelper logger)
42+
{
43+
_logger = logger;
44+
}
45+
46+
public void LogError(string message, params object[] messageArgs)
47+
{
48+
_logger.LogError(message, messageArgs);
49+
}
50+
51+
public void LogErrorFromException(Exception exception, bool showStackTrace)
52+
{
53+
_logger.LogErrorFromException(exception, showStackTrace);
54+
}
55+
56+
public void LogMessage(string message, params object[] messageArgs)
57+
{
58+
_logger.LogMessage(message, messageArgs);
59+
}
60+
61+
public void LogMessage(LogImportance importance, string message, params object[] messageArgs)
62+
{
63+
_logger.LogMessage((MessageImportance)importance, message, messageArgs);
64+
}
65+
66+
public void LogWarning(string message, params object[] messageArgs)
67+
{
68+
_logger.LogWarning(message, messageArgs);
69+
}
70+
71+
public bool HasLoggedErrors { get { return _logger.HasLoggedErrors; } }
72+
}
73+
74+
public enum LogImportance
75+
{
76+
Low = MessageImportance.Low,
77+
Normal = MessageImportance.Normal,
78+
High = MessageImportance.High
79+
}
80+
81+
82+
public interface ILog
83+
{
84+
//
85+
// Summary:
86+
// Logs an error with the specified message.
87+
//
88+
// Parameters:
89+
// message:
90+
// The message.
91+
//
92+
// messageArgs:
93+
// Optional arguments for formatting the message string.
94+
//
95+
// Exceptions:
96+
// T:System.ArgumentNullException:
97+
// message is null.
98+
void LogError(string message, params object[] messageArgs);
99+
100+
//
101+
// Summary:
102+
// Logs a message with the specified string.
103+
//
104+
// Parameters:
105+
// message:
106+
// The message.
107+
//
108+
// messageArgs:
109+
// The arguments for formatting the message.
110+
//
111+
// Exceptions:
112+
// T:System.ArgumentNullException:
113+
// message is null.
114+
void LogMessage(string message, params object[] messageArgs);
115+
116+
//
117+
// Summary:
118+
// Logs a message with the specified string and importance.
119+
//
120+
// Parameters:
121+
// importance:
122+
// One of the enumeration values that specifies the importance of the message.
123+
//
124+
// message:
125+
// The message.
126+
//
127+
// messageArgs:
128+
// The arguments for formatting the message.
129+
//
130+
// Exceptions:
131+
// T:System.ArgumentNullException:
132+
// message is null.
133+
void LogMessage(LogImportance importance, string message, params object[] messageArgs);
134+
135+
//
136+
// Summary:
137+
// Logs a warning with the specified message.
138+
//
139+
// Parameters:
140+
// message:
141+
// The message.
142+
//
143+
// messageArgs:
144+
// Optional arguments for formatting the message string.
145+
//
146+
// Exceptions:
147+
// T:System.ArgumentNullException:
148+
// message is null.
149+
void LogWarning(string message, params object[] messageArgs);
150+
}
151+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<Project>
2+
<PropertyGroup>
3+
<UseTargetFrameworkSDK>false</UseTargetFrameworkSDK>
4+
</PropertyGroup>
5+
<Import Project="..\..\Directory.Build.props" />
6+
</Project>

0 commit comments

Comments
 (0)