/// <summary>
    /// Conditionally set the dotnet.exe location, using the 32-bit dll when targeting x86
    /// </summary>
    public static T SetDotnetPath <T>(this T settings, MSBuildTargetPlatform platform)
        where T : ToolSettings
    {
        if (platform != MSBuildTargetPlatform.x86 && platform != MSBuildTargetPlatform.Win32)
        {
            return(settings);
        }


        // assume it's installed where we expect
        var dotnetPath = EnvironmentInfo.GetVariable <string>("DOTNET_EXE_32")
                         ?? Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), "dotnet", "dotnet.exe");

        if (!File.Exists(dotnetPath))
        {
            throw new Exception($"Error locating 32-bit dotnet process. Expected at '{dotnetPath}'");
        }

        return(settings.SetProcessToolPath(dotnetPath));
    }
 public static T SetPlatform <T>(this T settings, MSBuildTargetPlatform platform)
     where T : NuGetRestoreSettings
 {
     return(settings.SetProcessArgumentConfigurator(
                arg => arg.Add($"/p:\"Platform={platform}\"")));
 }
 private static string GetTargetPlatform(MSBuildTargetPlatform platform) =>
 platform == MSBuildTargetPlatform.MSIL ? "AnyCPU" : platform.ToString();
 public static DotNetPublishSettings SetTargetPlatform(this DotNetPublishSettings settings, MSBuildTargetPlatform platform)
 {
     return(platform is null
         ? settings
         : settings.SetProperty("Platform", GetTargetPlatform(platform)));
 }