Skip to content

Commit

Permalink
Install workload manifests in sdk band version derived from the (#81457)
Browse files Browse the repository at this point in the history
.. installer version.

- This is only for running Wasm.Build.Tests

Two new properties are added:

- `SdkBandVersionForWorkload_ComputedFromInstaller`: this is based on the
version derived from `dotnet --version`. `8.0.0-alpha.1.1234.1` becomes
`8.0.0-alpha.1`, and is used as the path where the manifests get installed for testing:
`sdk-manifests/$(SdkBandVersionForWorkload_ComputedFromInstaller)`

- `SdkBandVersionForWorkload_FromRuntimeVersions`: this is the version
band used for the packages generated. And simply rename of the earlier
`$(SdkBandVersionForWorkload)`.
  • Loading branch information
radical authored Feb 1, 2023
1 parent bf93d12 commit 70e791a
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 14 deletions.
2 changes: 1 addition & 1 deletion eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<PreReleaseVersionLabel>preview</PreReleaseVersionLabel>
<PreReleaseVersionIteration>1</PreReleaseVersionIteration>
<WorkloadVersionSuffix Condition="'$(PreReleaseVersionLabel)' != 'release'">-$(PreReleaseVersionLabel).$(PreReleaseVersionIteration)</WorkloadVersionSuffix>
<SdkBandVersionForWorkload>$(SdkBandVersion)$(WorkloadVersionSuffix)</SdkBandVersionForWorkload>
<SdkBandVersionForWorkload_FromRuntimeVersions>$(SdkBandVersion)$(WorkloadVersionSuffix)</SdkBandVersionForWorkload_FromRuntimeVersions>
<!-- Set assembly version to align with major and minor version,
as for the patches and revisions should be manually updated per assembly if it is serviced. -->
<AssemblyVersion>$(MajorVersion).$(MinorVersion).0.0</AssemblyVersion>
Expand Down
7 changes: 2 additions & 5 deletions eng/testing/tests.wasm.targets
Original file line number Diff line number Diff line change
Expand Up @@ -341,20 +341,17 @@
<WorkloadIdForTesting Include="wasm-tools;wasm-experimental"
ManifestName="Microsoft.NET.Workload.Mono.ToolChain.Current"
Variant="latest"
Version="$(PackageVersionForWorkloadManifests)"
VersionBand="$(SdkBandVersionForWorkload)" />
Version="$(PackageVersionForWorkloadManifests)" />

<WorkloadIdForTesting Include="wasm-tools-net7;wasm-experimental-net7"
ManifestName="Microsoft.NET.Workload.Mono.ToolChain.net7"
Variant="net7"
Version="$(PackageVersionForWorkloadManifests)"
VersionBand="$(SdkBandVersionForWorkload)" />
Version="$(PackageVersionForWorkloadManifests)" />

<WorkloadIdForTesting Include="wasm-tools-net6"
ManifestName="Microsoft.NET.Workload.Mono.ToolChain.net6"
Variant="net6"
Version="$(PackageVersionForWorkloadManifests)"
VersionBand="$(SdkBandVersionForWorkload)"
IgnoreErrors="$(WasmIgnoreNet6WorkloadInstallErrors)" />

<WorkloadCombinationsToInstall Include="latest" Variants="latest" />
Expand Down
39 changes: 37 additions & 2 deletions eng/testing/workloads-testing.targets
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@
<_SdkWithNoWorkloadStampPath>$([MSBuild]::NormalizePath($(_SdkWithNoWorkloadPath), '.version-for-none-$(SdkVersionForWorkloadTesting).stamp'))</_SdkWithNoWorkloadStampPath>
<InstallWorkloadUsingArtifactsDependsOn>
$(InstallWorkloadUsingArtifactsDependsOn);
_ProvisionDotNetForWorkloadTesting;
_GetDotNetVersion;
_SetPackageVersionForWorkloadsTesting;
_GetNuGetsToBuild;
_PreparePackagesForWorkloadInstall;
GetWorkloadInputs;
_ProvisionDotNetForWorkloadTesting;
_InstallWorkloads
</InstallWorkloadUsingArtifactsDependsOn>
</PropertyGroup>
Expand Down Expand Up @@ -85,6 +86,39 @@
<RemoveDir Directories="@(_ManifestsToRemove)" Condition="Exists(%(_ManifestsToRemove.Identity))" />
</Target>

<Target Name="_GetDotNetVersion">
<PropertyGroup>
<_DotNetPath>$([MSBuild]::NormalizePath($(_SdkWithNoWorkloadPath), 'dotnet'))</_DotNetPath>
<_DotNetPath Condition="$([MSBuild]::IsOSPlatform('windows'))">$(_DotNetPath).exe</_DotNetPath>
<_DotNetVersionCommand>$(_DotNetPath) --version</_DotNetVersionCommand>
</PropertyGroup>

<Exec Command="$(_DotNetVersionCommand)" ConsoleToMsBuild="true" StandardOutputImportance="Low" IgnoreExitCode="true">
<Output TaskParameter="ConsoleOutput" PropertyName="_DotNetVersionOutput" />
<Output TaskParameter="ExitCode" PropertyName="_DotNetVersionExitCode" />
</Exec>

<!-- If `dotnet -version` failed, then run it again, so we can surface the output as *Errors*.
This allows the errors to show up correctly, versus trying to use the output lines with
the Error task -->
<Exec Condition="$(_DotNetVersionExitCode) != '0'" Command="$(_DotNetVersionCommand)" CustomErrorRegularExpression=".*" />

<PropertyGroup>
<SdkBandVersionForWorkload_ComputedFromInstaller>$(SdkBandVersion)$([System.Text.RegularExpressions.Regex]::Match($(_DotNetVersionOutput), `-[A-z]*[\.]*\d*`))</SdkBandVersionForWorkload_ComputedFromInstaller>
</PropertyGroup>

<Message Text="** Using sdk band version for installing manifests: $(SdkBandVersionForWorkload_ComputedFromInstaller)" Importance="High" />
<Message Text="
********************
Warning: Using sdk band version for installing manifests: $(SdkBandVersionForWorkload_ComputedFromInstaller),
but the sdk band version in runtime is : $(SdkBandVersionForWorkload_FromRuntimeVersions)
********************"
Condition="$(SdkBandVersionForWorkload_ComputedFromInstaller) != $(SdkBandVersionForWorkload_FromRuntimeVersions)"
Importance="High" />
</Target>

<Target Name="_SetPackageVersionForWorkloadsTesting">
<PropertyGroup>
<!-- Used for workload testing -->
Expand Down Expand Up @@ -226,7 +260,8 @@
<InstallWorkloadFromArtifacts
WorkloadIds="@(WorkloadIdForTesting)"
InstallTargets="@(_SdkWithWorkloadToInstall)"
VersionBand="$(SdkBandVersionForWorkload)"
VersionBandForSdkManifestsDir="$(SdkBandVersionForWorkload_ComputedFromInstaller)"
VersionBandForManifestPackages="$(SdkBandVersionForWorkload_FromRuntimeVersions)"
LocalNuGetsPath="$(LibrariesShippingPackagesDir)"
TemplateNuGetConfigPath="$(RepoRoot)NuGet.config"
SdkWithNoWorkloadInstalledPath="$(_SdkWithNoWorkloadPath)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@
</PropertyGroup>

<Target Name="_PrepareForPack" BeforeTargets="GetPackageFiles" Returns="@(PackageFile)">
<Error Condition="'$(SdkBandVersionForWorkload_FromRuntimeVersions)' == ''"
Text="%24(SdkBandVersionForWorkload_FromRuntimeVersions) is not set" />

<!-- Override the id to include the sdk band as per the workload installer spec -->
<PropertyGroup>
<Id>Microsoft.NET.Workload.Mono.ToolChain.Current.Manifest-$(SdkBandVersionForWorkload)</Id>
<Id>Microsoft.NET.Workload.Mono.ToolChain.Current.Manifest-$(SdkBandVersionForWorkload_FromRuntimeVersions)</Id>
</PropertyGroup>

<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@
</PropertyGroup>

<Target Name="_PrepareForPack" BeforeTargets="GetPackageFiles" Returns="@(PackageFile)">
<Error Condition="'$(SdkBandVersionForWorkload_FromRuntimeVersions)' == ''"
Text="%24(SdkBandVersionForWorkload_FromRuntimeVersions) is not set" />

<!-- Override the id to include the sdk band as per the workload installer spec -->
<PropertyGroup>
<Id>Microsoft.NET.Workload.Mono.ToolChain.net6.Manifest-$(SdkBandVersionForWorkload)</Id>
<Id>Microsoft.NET.Workload.Mono.ToolChain.net6.Manifest-$(SdkBandVersionForWorkload_FromRuntimeVersions)</Id>
</PropertyGroup>

<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@
</PropertyGroup>

<Target Name="_PrepareForPack" BeforeTargets="GetPackageFiles" Returns="@(PackageFile)">
<Error Condition="'$(SdkBandVersionForWorkload_FromRuntimeVersions)' == ''"
Text="%24(SdkBandVersionForWorkload_FromRuntimeVersions) is not set" />

<!-- Override the id to include the sdk band as per the workload installer spec -->
<PropertyGroup>
<Id>Microsoft.NET.Workload.Mono.ToolChain.net7.Manifest-$(SdkBandVersionForWorkload)</Id>
<Id>Microsoft.NET.Workload.Mono.ToolChain.net7.Manifest-$(SdkBandVersionForWorkload_FromRuntimeVersions)</Id>
</PropertyGroup>

<PropertyGroup>
Expand Down
9 changes: 6 additions & 3 deletions src/tasks/WorkloadBuildTasks/InstallWorkloadFromArtifacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ public class InstallWorkloadFromArtifacts : Task
public ITaskItem[] InstallTargets { get; set; } = Array.Empty<ITaskItem>();

[Required, NotNull]
public string? VersionBand { get; set; }
public string? VersionBandForSdkManifestsDir { get; set; }

[Required, NotNull]
public string? VersionBandForManifestPackages { get; set; }

[Required, NotNull]
public string? LocalNuGetsPath { get; set; }
Expand Down Expand Up @@ -301,7 +304,7 @@ private bool InstallWorkloadManifest(ITaskItem workloadId, string name, string v
// Multiple directories for a manifest, differing only in case causes
// workload install to fail due to duplicate manifests!
// This is applicable only on case-sensitive filesystems
string manifestVersionBandDir = Path.Combine(sdkDir, "sdk-manifests", VersionBand);
string manifestVersionBandDir = Path.Combine(sdkDir, "sdk-manifests", VersionBandForSdkManifestsDir);
if (!Directory.Exists(manifestVersionBandDir))
{
Log.LogMessage(MessageImportance.Low, $" Could not find {manifestVersionBandDir}. Creating it..");
Expand All @@ -310,7 +313,7 @@ private bool InstallWorkloadManifest(ITaskItem workloadId, string name, string v

string outputDir = FindSubDirIgnoringCase(manifestVersionBandDir, name);

PackageReference pkgRef = new(Name: $"{name}.Manifest-{VersionBand}",
PackageReference pkgRef = new(Name: $"{name}.Manifest-{VersionBandForManifestPackages}",
Version: version,
OutputDir: outputDir,
relativeSourceDir: "data");
Expand Down

0 comments on commit 70e791a

Please sign in to comment.