Skip to content
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

[dotnet] Create and ship a WorkloadDependencies.json file. Fixes #21768. #21779

Merged
merged 5 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dotnet/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ tmpdir
Workloads/Microsoft.NET.Sdk.*/LICENSE
WorkloadManifest.json
WorkloadManifest.targets
WorkloadDependencies.json
nupkgs
Microsoft.*.Sdk/targets/Microsoft.*.Sdk.ImplicitNamespaceImports.props
Microsoft.*.Sdk/targets/Microsoft.*.Sdk.SupportedTargetPlatforms.props
Expand Down
8 changes: 8 additions & 0 deletions dotnet/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ $(foreach platform,$(DOTNET_PLATFORMS),$(eval $(call SupportedTargetPlatforms,$(

include $(TOP)/scripts/generate-workloadmanifest-json/fragment.mk
include $(TOP)/scripts/generate-workloadmanifest-targets/fragment.mk
include $(TOP)/scripts/generate-workloaddependencies-json/fragment.mk
define WorkloadTargets
Workloads/Microsoft.NET.Sdk.$(1)/WorkloadManifest.json: Makefile $(TOP)/Make.config.inc $(GIT_DIRECTORY)/HEAD $(GIT_DIRECTORY)/index Makefile $(GENERATE_WORKLOADMANIFEST_JSON) | Workloads/Microsoft.NET.Sdk.$(1)
$$(Q) rm -f $$@.tmp
Expand All @@ -194,15 +195,22 @@ Workloads/Microsoft.NET.Sdk.$(1)/WorkloadManifest.targets: Makefile $(TOP)/Make.
$$(Q_GEN) $(GENERATE_WORKLOADMANIFEST_TARGETS_EXEC) "$(1)" "$$@.tmp" "$$(DOTNET_WINDOWS_PLATFORMS)" "$(DOTNET_TFM)_$$($(4)_NUGET_OS_VERSION)" "$(SUPPORTED_API_VERSIONS_$(4))"
$$(Q) mv $$@.tmp $$@

Workloads/Microsoft.NET.Sdk.$(1)/WorkloadDependencies.json: Makefile $(TOP)/Make.config.inc $(GIT_DIRECTORY)/HEAD $(GIT_DIRECTORY)/index Makefile $(GENERATE_WORKLOADDEPENDENCIES_JSON) | Workloads/Microsoft.NET.Sdk.$(1)
$$(Q) rm -f $$@.tmp
$$(Q_GEN) $(GENERATE_WORKLOADDEPENDENCIES_JSON_EXEC) "$(1)" "$$($(4)_NUGET_VERSION_NO_METADATA)" "$(XCODE_VERSION)" "$$($(4)_NUGET_OS_VERSION)" "$$@.tmp"
$$(Q) mv $$@.tmp $$@

Workloads/Microsoft.NET.Sdk.$(1)/LICENSE: $(TOP)/LICENSE | Workloads/Microsoft.NET.Sdk.$(1)
$$(Q) $(CP) $$< $$@

WORKLOAD_TARGETS += Workloads/Microsoft.NET.Sdk.$(1)/WorkloadManifest.json
WORKLOAD_TARGETS += Workloads/Microsoft.NET.Sdk.$(1)/WorkloadManifest.targets
WORKLOAD_TARGETS += Workloads/Microsoft.NET.Sdk.$(1)/WorkloadDependencies.json
WORKLOAD_TARGETS += Workloads/Microsoft.NET.Sdk.$(1)/LICENSE

LOCAL_WORKLOAD_TARGETS += Workloads/Microsoft.NET.Sdk.$(1)/WorkloadManifest.json
LOCAL_WORKLOAD_TARGETS += Workloads/Microsoft.NET.Sdk.$(1)/WorkloadManifest.targets
LOCAL_WORKLOAD_TARGETS += Workloads/Microsoft.NET.Sdk.$(1)/WorkloadDependencies.json
LOCAL_WORKLOAD_TARGETS += Workloads/Microsoft.NET.Sdk.$(1)/LICENSE
endef
$(foreach platform,$(DOTNET_PLATFORMS),$(eval $(call WorkloadTargets,$(platform),$(shell echo $(platform) | tr A-Z a-z),$($(platform)_NUGET_VERSION_NO_METADATA),$(shell echo $(platform) | tr a-z A-Z),$(NET8_$(platform)_NUGET_VERSION_NO_METADATA))))
Expand Down
1 change: 1 addition & 0 deletions dotnet/package/microsoft.workloads.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
<ItemGroup>
<!-- workload .nupkg contents should go in /data/ -->
<Content Update="$(_packagePath)WorkloadManifest.*" PackagePath="data" />
<Content Update="$(_packagePath)WorkloadDependencies.json" PackagePath="data" />
</ItemGroup>
</Project>
1 change: 1 addition & 0 deletions scripts/generate-workloaddependencies-json/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# generate-workload-dependencies
2 changes: 2 additions & 0 deletions scripts/generate-workloaddependencies-json/fragment.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include $(TOP)/scripts/template.mk
$(eval $(call TemplateScript,GENERATE_WORKLOADDEPENDENCIES_JSON,generate-workloaddependencies-json))
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// arguments are: <platform> <version> <xcodeVersion> <sdkVersion> <outputPath>

using System.IO;
using System.Xml;

var expectedArgumentCount = 5;
if (args.Length != expectedArgumentCount) {
Console.WriteLine ($"Need {expectedArgumentCount} arguments, got {args.Length}");
return 1;
}

var argumentIndex = 0;
var platform = args [argumentIndex++];
var version = args [argumentIndex++];
var xcodeVersion = args [argumentIndex++];
var sdkVersion = args [argumentIndex++];
var outputPath = args [argumentIndex++];

var platformLowerCase = platform.ToLowerInvariant ();

using (var writer = new StreamWriter (outputPath)) {
writer.WriteLine ($"{{");
writer.WriteLine ($" \"microsoft.net.sdk.{platformLowerCase}\": {{");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is microsoft.net.sdk.[platform] the right key? Or should it be the workload name?

I think we want a mapping "required Xcode" -> iOS workload, and not a relationship between a "required Xcode" -> "workload manifest"?

Mainly thinking if we need .NET SDK team to review.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, you could have multiple workloads within one manifest, that has different requirements per workload?

For example, we might have a android-nativeaot workload one day that requires the Android NDK and the plain android workload doesn't.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we do want the actual workload identifier here as is in the PR. The aliases were meant to capture the name we might use in the CLI, but for looking up this type of info, for example, C:\Program Files\dotnet\sdk-manifests\9.0.100\microsoft.net.sdk.ios\[version]\WorkloadDependencies.json is where i'd expect to find the info, so I think it makes sense for the key in this file to match the id here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would we define one workload as having different requirements as the other?

For example, here in .NET 9 Preview 6:

We would require API-34 for the android workload and API-35 for the preview android-35 workload.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we've mostly sorted this out for now. Android is listing these as optional, and we'll eventually add a way to query the context for a given project state (probably invoking a specific msbuild target on a project) at which point having a net9.0-android35.0 TFM for example could cause the returned info to require the sdk package for android 35 instead of the default 34 for net9.0 as per the file in the workload.

In the case of macios, I don't think this will be a problem as the workload doesn't differentiate anywhere at this point that different xcode versions would be needed for different target platform versions for example.

writer.WriteLine ($" \"workload\": {{");
writer.WriteLine ($" \"alias\": [ \"{platformLowerCase}\" ],");
writer.WriteLine ($" \"version\": \"{version}\"");
writer.WriteLine ($" }},");
writer.WriteLine ($" \"xcode\": {{");
writer.WriteLine ($" \"version\": \"[{xcodeVersion},)\",");
writer.WriteLine ($" \"recommendedVersion\": \"{xcodeVersion}\"");
writer.WriteLine ($" }},");
writer.WriteLine ($" \"sdk\": {{");
writer.WriteLine ($" \"version\": \"{sdkVersion}\"");
writer.WriteLine ($" }}");
writer.WriteLine ($" }}");
writer.WriteLine ($"}}");
}

return 0;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net$(BundledNETCoreAppTargetFrameworkVersion)</TargetFramework>
</PropertyGroup>
</Project>
Loading