-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add workload restore command #18910
Add workload restore command #18910
Conversation
I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label. |
</PropertyGroup> | ||
</Target> | ||
|
||
<Target Name="_FindAllReferenceWorkload" DependsOnTargets="_SetSkipResolvePackageAssets;GetSuggestedWorkloads;PrepareProjectReferences" Returns="@(_ResolvedSuggestedWorkloads)"> |
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.
@dsplaisted help me double check the RemoveProperties are right
============================================================ | ||
--> | ||
|
||
<Target Name="_FindAllReferenceWorkload" |
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.
@dsplaisted I end up adding a outer build version instead using the same one
src/Cli/dotnet/commands/dotnet-workload/restore/WorkloadRestoreCommand.cs
Outdated
Show resolved
Hide resolved
src/Cli/dotnet/commands/dotnet-workload/restore/WorkloadRestoreCommand.cs
Outdated
Show resolved
Hide resolved
src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.ImportWorkloads.targets
Outdated
Show resolved
Hide resolved
Projects="@(_MSBuildProjectReferenceExistent)" | ||
Targets="GetSuggestedWorkloads" | ||
BuildInParallel="$(BuildInParallel)" | ||
Properties="%(_MSBuildProjectReferenceExistent.SetConfiguration); %(_MSBuildProjectReferenceExistent.SetPlatform); GenerateErrorsForMissingWorkloads=false; SkipResolvePackageAssets=true" |
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.
Likewise here, are these properties avoidable?
src/Cli/dotnet/commands/dotnet-workload/restore/WorkloadRestoreCommand.cs
Outdated
Show resolved
Hide resolved
...Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.ImportWorkloadsCrossTarget.targets
Outdated
Show resolved
Hide resolved
3fe20dd
to
3912692
Compare
src/Cli/dotnet/commands/dotnet-workload/restore/WorkloadRestoreCommandParser.cs
Show resolved
Hide resolved
|
||
[Fact] | ||
public void WhenCallWithDirectoryWith2ProjectItShouldFindAll() | ||
{ |
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 don't see any tests confirming we can get from the project/sln arg in the parse result to a resolved list of projects
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.
WhenCallWithSlnOrProjectArgumentItCollectProjectsFromSolution is the pass in example
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.
But it's not covering the parsing/ reading the parse result value
@dsplaisted Rainer checked msbuild part too, so I think it won't be too bad. I'll get it in once test passes. |
efd9c34
to
ad609bf
Compare
internal static List<string> DiscoverAllProjects(string currentDirectory, | ||
IEnumerable<string> slnOrProjectArgument = null) |
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 don't think we should discover all projects here. We should do the same thing as MSBuild, which is more or less to expect that there is a single project or solution file in the directory, and error out if not. The actual logic is in ProcessProjectSwitch
: https://github.com/dotnet/msbuild/blob/1d845f30213e9ba4f36d4d5a366c0cc8285eed6e/src/MSBuild/XMake.cs#L2763
Ideally we wouldn't have to duplicate the logic. It looks like RunCommand
has a simple form of it (FindSingleProjectInDirectory
) which only looks for project files, not solution files.
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 thought about the same thing, but why make it difficult. I started with refactoring RunCommand. But when there are 2 projects in the folder what the user should do? It is valid, and workload restore can handle it (unlike runcommand), why fail and ask the user to input one by one?
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.
All other MSBuild and dotnet commands require you to specify the project if there is more than one in the folder. It seems weird to make dotnet workload restore
the one exception.
src/Cli/dotnet/commands/dotnet-workload/restore/LocalizableStrings.resx
Outdated
Show resolved
Hide resolved
src/Cli/dotnet/commands/dotnet-workload/restore/WorkloadRestoreCommand.cs
Outdated
Show resolved
Hide resolved
{ | ||
var globalProperties = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase) | ||
{ | ||
{Constants.MSBuildExtensionsPath, AppContext.BaseDirectory}, |
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.
This was a bit confusing to me. I see that RunCommand
does the same thing, but it would be nice to have a comment explaining this.
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.
Removed the line. It still works.
src/Cli/dotnet/commands/dotnet-workload/restore/WorkloadRestoreCommandParser.cs
Show resolved
Hide resolved
src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.ImportWorkloads.targets
Outdated
Show resolved
Hide resolved
src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.ImportWorkloads.targets
Outdated
Show resolved
Hide resolved
|
||
getValuesCommand.GetValues() | ||
.Should() | ||
.BeEquivalentTo("microsoft-android-sdk-full", "microsoft-net-runtime-mono-tooling"); |
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 think these names are changing, you may want to update stage 0 and see if that includes the rename so that this test doesn't start failing when it happens.
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.
due to #19021 I will update stage 0 in a different 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.
Some suggestions for the targets!
...rosoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.GetRequiredWorkloads.CrossTargeting.targets
Outdated
Show resolved
Hide resolved
...Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.ImportWorkloadsCrossTarget.targets
Outdated
Show resolved
Hide resolved
@@ -13,5 +13,6 @@ Copyright (c) .NET Foundation. All rights reserved. | |||
|
|||
<Import Project="$(MSBuildThisFileDirectory)Microsoft.NET.DefaultAssemblyInfo.targets" /> | |||
<Import Project="$(MSBuildThisFileDirectory)Microsoft.NET.DefaultOutputPaths.targets" /> | |||
<Import Project="$(MSBuildThisFileDirectory)Microsoft.NET.Sdk.GetRequiredWorkloads.CrossTargeting.targets" /> |
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.
This targets file is meant to have multi-targeting/outer-build logic for Workloads, right?
So, the following name below might make more sense!
<Import Project="$(MSBuildThisFileDirectory)Microsoft.NET.Sdk.GetRequiredWorkloads.CrossTargeting.targets" /> | |
<Import Project="$(MSBuildThisFileDirectory)Microsoft.NET.Sdk.Workloads.CrossTargeting.targets" /> |
src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.TargetFrameworkInference.targets
Outdated
Show resolved
Hide resolved
src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.PackageDependencyResolution.targets
Outdated
Show resolved
Hide resolved
...rosoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.GetRequiredWorkloads.CrossTargeting.targets
Outdated
Show resolved
Hide resolved
@dsplaisted all issue addressed |
@dsplaisted I'll merge once tests pass |
Adding _FindAllReferenceWorkload target to find workloads in project. Discover the projects and then pipe all arguements to workload install command
Adding _FindAllReferenceWorkload target to find workloads in project.
Discover the projects and then pipe all arguements to workload install
command