-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Make Microsoft.NETCore.Platforms pack from CSProj #50468
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
7fcec2b
Use CSProj for packing Platforms package
ericstj d3d6392
Port GenerateRuntimeGraph task
ericstj b82c38f
Refactor GenerateRuntimeGraph into separate files
ericstj f7ce36b
Add test for GenerateRuntimeGraph
ericstj 63adcb3
Fix up path to runtime.json
ericstj 4682bce
Don't filter inner builds when building Platforms task
ericstj 0b8d0e0
Skip tests RuntimeGraph task tests on some platforms
ericstj 7a6ccaf
Exclude browser from testing instead of wasm
ericstj 5aec6a7
Another try at suppressing testing on Browser
ericstj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add test for GenerateRuntimeGraph
- Loading branch information
commit f7ce36b812425d5cc90dce27eb6e13394e765e01
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
src/libraries/Microsoft.NETCore.Platforms/Microsoft.NETCore.Platforms.sln
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| | ||
| Microsoft Visual Studio Solution File, Format Version 12.00 | ||
| # Visual Studio Version 16 | ||
| VisualStudioVersion = 16.0.31004.24 | ||
| MinimumVisualStudioVersion = 10.0.40219.1 | ||
| Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.NETCore.Platforms", "src\Microsoft.NETCore.Platforms.csproj", "{BFFF96CC-06AA-4291-9F93-3E77F23DBB11}" | ||
| EndProject | ||
| Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.NETCore.Platforms.Tests", "tests\Microsoft.NETCore.Platforms.Tests.csproj", "{0C60F372-5C73-4BFA-9B91-5659C88F9750}" | ||
| EndProject | ||
| Global | ||
| GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
| Debug|Any CPU = Debug|Any CPU | ||
| Release|Any CPU = Release|Any CPU | ||
| EndGlobalSection | ||
| GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
| {BFFF96CC-06AA-4291-9F93-3E77F23DBB11}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
| {BFFF96CC-06AA-4291-9F93-3E77F23DBB11}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
| {BFFF96CC-06AA-4291-9F93-3E77F23DBB11}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
| {BFFF96CC-06AA-4291-9F93-3E77F23DBB11}.Release|Any CPU.Build.0 = Release|Any CPU | ||
| {0C60F372-5C73-4BFA-9B91-5659C88F9750}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
| {0C60F372-5C73-4BFA-9B91-5659C88F9750}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
| {0C60F372-5C73-4BFA-9B91-5659C88F9750}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
| {0C60F372-5C73-4BFA-9B91-5659C88F9750}.Release|Any CPU.Build.0 = Release|Any CPU | ||
| EndGlobalSection | ||
| GlobalSection(SolutionProperties) = preSolution | ||
| HideSolutionNode = FALSE | ||
| EndGlobalSection | ||
| GlobalSection(ExtensibilityGlobals) = postSolution | ||
| SolutionGuid = {E946A528-C3E7-48EC-AD6D-AE84ED2B11AC} | ||
| EndGlobalSection | ||
| EndGlobal |
58 changes: 58 additions & 0 deletions
58
src/libraries/Microsoft.NETCore.Platforms/tests/GenerateRuntimeGraphTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System.Linq; | ||
| using Microsoft.Build.Evaluation; | ||
| using Microsoft.Build.Framework; | ||
| using Microsoft.Build.Utilities; | ||
| using Xunit; | ||
| using Xunit.Abstractions; | ||
|
|
||
| namespace Microsoft.NETCore.Platforms.BuildTasks.Tests | ||
| { | ||
| public class GenerateRuntimeGraphTests | ||
| { | ||
| private Log _log; | ||
| private TestBuildEngine _engine; | ||
|
|
||
| public GenerateRuntimeGraphTests(ITestOutputHelper output) | ||
| { | ||
| _log = new Log(output); | ||
| _engine = new TestBuildEngine(_log); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void CanCreateRuntimeGraph() | ||
| { | ||
| string runtimeFile = "runtime.json"; | ||
|
|
||
| Project runtimeGroupProps = new Project("runtimeGroups.props"); | ||
|
|
||
| ITaskItem[] runtimeGroups = runtimeGroupProps.GetItems("RuntimeGroupWithQualifiers") | ||
| .Select(i => CreateItem(i)).ToArray(); | ||
|
|
||
| Assert.NotEmpty(runtimeGroups); | ||
|
|
||
| // will generate and compare to existing file. | ||
| GenerateRuntimeGraph task = new GenerateRuntimeGraph() | ||
| { | ||
| BuildEngine = _engine, | ||
| RuntimeGroups = runtimeGroups, | ||
| RuntimeJson = runtimeFile | ||
| }; | ||
| task.Execute(); | ||
|
|
||
| _log.AssertNoErrorsOrWarnings(); | ||
| } | ||
|
|
||
| private static ITaskItem CreateItem(ProjectItem projectItem) | ||
| { | ||
| TaskItem item = new TaskItem(projectItem.EvaluatedInclude); | ||
| foreach(var metadatum in projectItem.Metadata) | ||
| { | ||
| item.SetMetadata(metadatum.Name, metadatum.EvaluatedValue); | ||
| } | ||
| return item; | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using Xunit; | ||
| using Xunit.Abstractions; | ||
|
|
||
| namespace Microsoft.NETCore.Platforms.BuildTasks.Tests | ||
| { | ||
| internal class Log : ILog | ||
| { | ||
| private readonly ITestOutputHelper _output; | ||
|
|
||
| public Log(ITestOutputHelper output) | ||
| { | ||
| _output = output; | ||
| Reset(); | ||
| } | ||
|
|
||
| public int ErrorsLogged { get; set; } | ||
| public int WarningsLogged { get; set; } | ||
|
|
||
| public void LogError(string message, params object[] messageArgs) | ||
| { | ||
| ErrorsLogged++; | ||
| _output.WriteLine("Error: " + message, messageArgs); | ||
| } | ||
|
|
||
| public void LogMessage(string message, params object[] messageArgs) | ||
| { | ||
| _output.WriteLine(message, messageArgs); | ||
| } | ||
|
|
||
| public void LogMessage(LogImportance importance, string message, params object[] messageArgs) | ||
| { | ||
| _output.WriteLine(message, messageArgs); | ||
| } | ||
|
|
||
| public void LogWarning(string message, params object[] messageArgs) | ||
| { | ||
| WarningsLogged++; | ||
| _output.WriteLine("Warning: " + message, messageArgs); | ||
| } | ||
|
|
||
| public void Reset() | ||
| { | ||
| ErrorsLogged = 0; | ||
| WarningsLogged = 0; | ||
| } | ||
|
|
||
| public void AssertNoErrorsOrWarnings() | ||
| { | ||
| Assert.Equal(0, ErrorsLogged); | ||
| Assert.Equal(0, WarningsLogged); | ||
| } | ||
| } | ||
| } |
22 changes: 22 additions & 0 deletions
22
src/libraries/Microsoft.NETCore.Platforms/tests/Microsoft.NETCore.Platforms.Tests.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
| <PropertyGroup> | ||
| <TargetFrameworks>$(NetCoreAppCurrent);net472</TargetFrameworks> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <ProjectReference Include="..\src\Microsoft.NETCore.Platforms.csproj" /> | ||
| <!-- Workaround NuGet promoting this to a ProjectReference --> | ||
| <PackageReference Include="System.Memory" Condition="'$(TargetFramework)' == 'net472'" Version="$(SystemMemoryVersion)" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <Compile Include="GenerateRuntimeGraphTests.cs" /> | ||
| <Compile Include="Log.cs" /> | ||
| <Compile Include="TestBuildEngine.cs" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <Content Include="..\src\runtimeGroups.props" CopyToOutputDirectory="PreserveNewest" /> | ||
| <Content Include="..\src\runtime.json" CopyToOutputDirectory="PreserveNewest" /> | ||
| </ItemGroup> | ||
| </Project> | ||
56 changes: 56 additions & 0 deletions
56
src/libraries/Microsoft.NETCore.Platforms/tests/TestBuildEngine.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using Microsoft.Build.Framework; | ||
| using System; | ||
| using System.Collections; | ||
|
|
||
| namespace Microsoft.NETCore.Platforms.BuildTasks.Tests | ||
| { | ||
| public class TestBuildEngine : IBuildEngine | ||
| { | ||
| private ILog _log; | ||
|
|
||
| public TestBuildEngine(ILog log) | ||
| { | ||
| ColumnNumberOfTaskNode = 0; | ||
| ContinueOnError = true; | ||
| LineNumberOfTaskNode = 0; | ||
| ProjectFileOfTaskNode = "test"; | ||
| _log = log; | ||
| } | ||
|
|
||
| public int ColumnNumberOfTaskNode { get; set; } | ||
|
|
||
| public bool ContinueOnError { get; set; } | ||
|
|
||
| public int LineNumberOfTaskNode { get; set; } | ||
|
|
||
| public string ProjectFileOfTaskNode { get; set; } | ||
|
|
||
| public bool BuildProjectFile(string projectFileName, string[] targetNames, IDictionary globalProperties, IDictionary targetOutputs) | ||
| { | ||
| throw new NotImplementedException(); | ||
| } | ||
|
|
||
| public void LogCustomEvent(CustomBuildEventArgs e) | ||
| { | ||
| _log.LogMessage(e.Message); | ||
| } | ||
|
|
||
| public void LogErrorEvent(BuildErrorEventArgs e) | ||
| { | ||
| _log.LogError(e.Message); | ||
| } | ||
|
|
||
| public void LogMessageEvent(BuildMessageEventArgs e) | ||
| { | ||
| _log.LogMessage((LogImportance)e.Importance, e.Message); | ||
| } | ||
|
|
||
| public void LogWarningEvent(BuildWarningEventArgs e) | ||
| { | ||
| _log.LogWarning(e.Message); | ||
| } | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Can you please elaborate? Why does NuGet add a P2P for System.Memory?
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.
NuGet tried to restore System.Memory.csproj for
net472without this and restore failed. I believe it's because it's in the closure for the project added by the test targets. I think it's the same issue as NuGet/Home#9354.