File: src\Shared\MsBuildNodeHandshakeSalt.cs
Web Access
Project: src\src\Aspire.Hosting\Aspire.Hosting.csproj (Aspire.Hosting)
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
 
#if ASPIRE_HOSTING_CORE
namespace Aspire.Hosting.Internal;
#else
namespace Aspire.Hosting.Dotnet;
#endif
 
/// <summary>
/// Shares the MSBuild node handshake salt rules used by Aspire-managed .NET builds and by queries of their output.
/// </summary>
internal static class MsBuildNodeHandshakeSalt
{
    public const string EnvironmentVariableName = "MSBUILDNODEHANDSHAKESALT";
 
    /// <summary>
    /// Gets a value indicating whether Aspire-managed builds receive a per-run handshake salt on this platform.
    /// </summary>
    public static bool IsPerRunIsolationEnabled => OperatingSystem.IsWindows();
 
    /// <summary>
    /// Creates the MSBuild switch that sets <c>$(MSBUILDNODEHANDSHAKESALT)</c> to the original salt as a global property.
    /// </summary>
    public static string CreateOriginalValuePropertyArgument(string? originalSalt) =>
        MsBuildResponseFileFactory.CreatePropertyArgument(EnvironmentVariableName, originalSalt ?? string.Empty);
}