Skip to content

Runtime pack resolution #19596

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 9 commits into from
Aug 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using NuGet.Common;
using System.Text.Json;
using System.Runtime.InteropServices;
using Microsoft.DotNet.Cli;

namespace Microsoft.DotNet.Workloads.Workload.Install
{
Expand Down Expand Up @@ -138,7 +139,7 @@ public static void AdvertiseWorkloadUpdates()
{
try
{
var backgroundUpdatesDisabled = bool.TryParse(Environment.GetEnvironmentVariable("DOTNET_CLI_WORKLOAD_UPDATE_NOTIFY_DISABLE"), out var disableEnvVar) && disableEnvVar;
var backgroundUpdatesDisabled = bool.TryParse(Environment.GetEnvironmentVariable(EnvironmentVariableNames.WORKLOAD_UPDATE_NOTIFY_DISABLE), out var disableEnvVar) && disableEnvVar;
var adUpdatesFile = GetAdvertisingWorkloadsFilePath(CliFolderPathCalculator.DotnetHomePath);
if (!backgroundUpdatesDisabled && File.Exists(adUpdatesFile))
{
Expand Down Expand Up @@ -387,7 +388,7 @@ private bool AdManifestSentinalIsDueForUpdate()
{
var sentinalPath = GetAdvertisingManifestSentinalPath();
int updateIntervalHours;
if (!int.TryParse(_getEnvironmentVariable("DOTNET_CLI_WORKLOAD_UPDATE_NOTIFY_INTERVAL_HOURS"), out updateIntervalHours))
if (!int.TryParse(_getEnvironmentVariable(EnvironmentVariableNames.WORKLOAD_UPDATE_NOTIFY_INTERVAL_HOURS), out updateIntervalHours))
{
updateIntervalHours = 24;
}
Expand Down Expand Up @@ -438,7 +439,7 @@ private async Task<bool> NewerManifestPackageExists(ManifestId manifest)
}

private bool BackgroundUpdatesAreDisabled() =>
bool.TryParse(_getEnvironmentVariable("DOTNET_CLI_WORKLOAD_UPDATE_NOTIFY_DISABLE"), out var disableEnvVar) && disableEnvVar;
bool.TryParse(_getEnvironmentVariable(EnvironmentVariableNames.WORKLOAD_UPDATE_NOTIFY_DISABLE), out var disableEnvVar) && disableEnvVar;

private string GetAdvertisingManifestSentinalPath() => Path.Combine(_userHome, ".dotnet", ".workloadAdvertisingManifestSentinal");

Expand Down
1 change: 1 addition & 0 deletions src/Cli/dotnet/dotnet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<Compile Remove="commands\dotnet-new\**" />
<Compile Include="commands\dotnet-new\*.cs" />
<Compile Include="..\..\Resolvers\Microsoft.DotNet.MSBuildSdkResolver\FXVersion.cs" />
<Compile Include="$(RepoRoot)src\Common\EnvironmentVariableNames.cs" LinkBase="Common"/>
<EmbeddedResource Include="commands\dotnet-new\*.zip" />
<EmbeddedResource Update="**\*.resx" GenerateSource="true" />
<EmbeddedResource Update="*.resx" Namespace="Microsoft.DotNet.Tools" />
Expand Down
13 changes: 13 additions & 0 deletions src/Common/EnvironmentVariableNames.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace Microsoft.DotNet.Cli
{
static class EnvironmentVariableNames
{
public static readonly string WORKLOAD_PACK_ROOTS = "DOTNETSDK_WORKLOAD_PACK_ROOTS";
public static readonly string WORKLOAD_MANIFEST_ROOTS = "DOTNETSDK_WORKLOAD_MANIFEST_ROOTS";
public static readonly string WORKLOAD_UPDATE_NOTIFY_DISABLE = "DOTNET_CLI_WORKLOAD_UPDATE_NOTIFY_DISABLE";
public static readonly string WORKLOAD_UPDATE_NOTIFY_INTERVAL_HOURS = "DOTNET_CLI_WORKLOAD_UPDATE_NOTIFY_INTERVAL_HOURS";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
<ItemGroup>
<Compile Include="..\Resolvers\Microsoft.NET.Sdk.WorkloadManifestReader\**\*.cs" LinkBase="Microsoft.DotNet.SdkResolver"/>
<Compile Include="..\Resolvers\Microsoft.DotNet.MSBuildSdkResolver\FXVersion.cs" LinkBase="Microsoft.DotNet.SdkResolver"/>
<Compile Include="$(RepoRoot)src\Common\EnvironmentVariableNames.cs" LinkBase="Common"/>
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@
<Compile Include="..\..\Cli\dotnet\commands\dotnet-workload\install\WorkloadInstallRecords\**\*.cs"
Exclude="..\..\Cli\dotnet\commands\dotnet-workload\install\WorkloadInstallRecords\RegistryWorkloadInstallationRecordRepository.cs"
LinkBase="WorkloadInstallRecords" />

<Compile Include="$(RepoRoot)src\Common\EnvironmentVariableNames.cs" LinkBase="Common"/>
</ItemGroup>

<ItemGroup Condition="'$(TargetFrameworkIdentifier)' != '.NETFramework'">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<ItemGroup>
<EmbeddedResource Update="**\*.resx" GenerateSource="true" Namespace="Microsoft.NET.Sdk.Localization" />
<Compile Include="..\Microsoft.DotNet.MSBuildSdkResolver\FXVersion.cs" />
<Compile Include="$(RepoRoot)src\Common\EnvironmentVariableNames.cs" LinkBase="Common"/>
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Microsoft.DotNet.Cli;

namespace Microsoft.NET.Sdk.WorkloadManifestReader
{
Expand Down Expand Up @@ -53,7 +54,7 @@ static int Last2DigitsTo0(int versionBuild)

var manifestDirectory = Path.Combine(_sdkRootPath, "sdk-manifests", _sdkVersionBand);

var manifestDirectoryEnvironmentVariable = getEnvironmentVariable("DOTNETSDK_WORKLOAD_MANIFEST_ROOTS");
var manifestDirectoryEnvironmentVariable = getEnvironmentVariable(EnvironmentVariableNames.WORKLOAD_MANIFEST_ROOTS);
if (manifestDirectoryEnvironmentVariable != null)
{
// Append the SDK version band to each manifest root specified via the environment variable. This allows the same
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;

using Microsoft.DotNet.Cli;
using Microsoft.NET.Sdk.Localization;
using FXVersion = Microsoft.DotNet.MSBuildSdkResolver.FXVersion;

Expand Down Expand Up @@ -34,7 +34,7 @@ public static WorkloadResolver Create(IWorkloadManifestProvider manifestProvider
File.ReadAllLines(runtimeIdentifierChainPath).Where(l => !string.IsNullOrEmpty(l)).ToArray() :
new string[] { };

var packRootEnvironmentVariable = Environment.GetEnvironmentVariable("DOTNETSDK_WORKLOAD_PACK_ROOTS");
var packRootEnvironmentVariable = Environment.GetEnvironmentVariable(EnvironmentVariableNames.WORKLOAD_PACK_ROOTS);

string[] dotnetRootPaths;
if (!string.IsNullOrEmpty(packRootEnvironmentVariable))
Expand Down
4 changes: 4 additions & 0 deletions src/Tasks/Common/Resources/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -828,4 +828,8 @@ You may need to build the project on another operating system or architecture, o
<value>NETSDK1180: Specified runtime identifier '{0}'' implies Windows 7 compatibility. Single File publishing is not compatible with Windows 7.</value>
<comment>{StrBegin="NETSDK1180: "}</comment>
</data>
<data name="CouldNotGetPackVersionFromWorkloadManifests" xml:space="preserve">
<value>NETSDK1181: Error getting pack version: Pack '{0}' was not present in workload manifests.</value>
<comment>{StrBegin="NETSDK1181: "}</comment>
</data>
</root>
5 changes: 5 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.cs.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,11 @@
<target state="translated">Vítěze nebylo možné určit, protože {0} není sestavení.</target>
<note />
</trans-unit>
<trans-unit id="CouldNotGetPackVersionFromWorkloadManifests">
<source>NETSDK1181: Error getting pack version: Pack '{0}' was not present in workload manifests.</source>
<target state="new">NETSDK1181: Error getting pack version: Pack '{0}' was not present in workload manifests.</target>
<note>{StrBegin="NETSDK1181: "}</note>
</trans-unit>
<trans-unit id="CouldNotLoadPlatformManifest">
<source>NETSDK1042: Could not load PlatformManifest from '{0}' because it did not exist.</source>
<target state="translated">NETSDK1042: Ze souboru {0} nebylo možné načíst manifest platformy, protože neexistoval.</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.de.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,11 @@
<target state="translated">Der Gewinner konnte nicht bestimmt werden, weil es sich bei "{0}" nicht um eine Assembly handelt.</target>
<note />
</trans-unit>
<trans-unit id="CouldNotGetPackVersionFromWorkloadManifests">
<source>NETSDK1181: Error getting pack version: Pack '{0}' was not present in workload manifests.</source>
<target state="new">NETSDK1181: Error getting pack version: Pack '{0}' was not present in workload manifests.</target>
<note>{StrBegin="NETSDK1181: "}</note>
</trans-unit>
<trans-unit id="CouldNotLoadPlatformManifest">
<source>NETSDK1042: Could not load PlatformManifest from '{0}' because it did not exist.</source>
<target state="translated">NETSDK1042: PlatformManifest konnte nicht von "{0}" geladen werden, weil es nicht vorhanden ist.</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.es.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,11 @@
<target state="new">Could not determine a winner because '{0}' is not an assembly.</target>
<note />
</trans-unit>
<trans-unit id="CouldNotGetPackVersionFromWorkloadManifests">
<source>NETSDK1181: Error getting pack version: Pack '{0}' was not present in workload manifests.</source>
<target state="new">NETSDK1181: Error getting pack version: Pack '{0}' was not present in workload manifests.</target>
<note>{StrBegin="NETSDK1181: "}</note>
</trans-unit>
<trans-unit id="CouldNotLoadPlatformManifest">
<source>NETSDK1042: Could not load PlatformManifest from '{0}' because it did not exist.</source>
<target state="new">NETSDK1042: Could not load PlatformManifest from '{0}' because it did not exist.</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.fr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,11 @@
<target state="translated">Impossible de déterminer un gagnant, car '{0}' n'est pas un assembly.</target>
<note />
</trans-unit>
<trans-unit id="CouldNotGetPackVersionFromWorkloadManifests">
<source>NETSDK1181: Error getting pack version: Pack '{0}' was not present in workload manifests.</source>
<target state="new">NETSDK1181: Error getting pack version: Pack '{0}' was not present in workload manifests.</target>
<note>{StrBegin="NETSDK1181: "}</note>
</trans-unit>
<trans-unit id="CouldNotLoadPlatformManifest">
<source>NETSDK1042: Could not load PlatformManifest from '{0}' because it did not exist.</source>
<target state="translated">NETSDK1042: Impossible de charger PlatformManifest à partir de '{0}', car il n'existe pas.</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.it.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,11 @@
<target state="translated">Non è stato possibile determinare la versione da usare perché '{0}' non è un assembly.</target>
<note />
</trans-unit>
<trans-unit id="CouldNotGetPackVersionFromWorkloadManifests">
<source>NETSDK1181: Error getting pack version: Pack '{0}' was not present in workload manifests.</source>
<target state="new">NETSDK1181: Error getting pack version: Pack '{0}' was not present in workload manifests.</target>
<note>{StrBegin="NETSDK1181: "}</note>
</trans-unit>
<trans-unit id="CouldNotLoadPlatformManifest">
<source>NETSDK1042: Could not load PlatformManifest from '{0}' because it did not exist.</source>
<target state="translated">NETSDK1042: non è stato possibile caricare PlatformManifest da '{0}' perché non esiste.</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.ja.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,11 @@
<target state="translated">'{0}' がアセンブリでないため勝者を判別できませんでした。</target>
<note />
</trans-unit>
<trans-unit id="CouldNotGetPackVersionFromWorkloadManifests">
<source>NETSDK1181: Error getting pack version: Pack '{0}' was not present in workload manifests.</source>
<target state="new">NETSDK1181: Error getting pack version: Pack '{0}' was not present in workload manifests.</target>
<note>{StrBegin="NETSDK1181: "}</note>
</trans-unit>
<trans-unit id="CouldNotLoadPlatformManifest">
<source>NETSDK1042: Could not load PlatformManifest from '{0}' because it did not exist.</source>
<target state="translated">NETSDK1042: 存在しなかったため、'{0}' から PlatformManifest を読み込めませんでした。</target>
Expand Down
Loading