dotnet-installer/src/dotnet/commands/dotnet-msbuild/MSBuildForwardingApp.cs

53 lines
1.6 KiB
C#
Raw Normal View History

// 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.
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;
2016-09-22 19:11:08 -05:00
using Microsoft.DotNet.Cli;
2016-09-22 19:11:08 -05:00
namespace Microsoft.DotNet.Tools.MSBuild
{
public class MSBuildForwardingApp
{
private const string s_msbuildExeName = "MSBuild.exe";
private readonly ForwardingApp _forwardingApp;
public MSBuildForwardingApp(IEnumerable<string> argsToForward)
{
_forwardingApp = new ForwardingApp(
GetMSBuildExePath(),
argsToForward,
environmentVariables: GetEnvironmentVariables());
}
public int Execute()
{
return _forwardingApp.Execute();
}
private static Dictionary<string, string> GetEnvironmentVariables()
{
return new Dictionary<string, string>
{
{ "MSBuildExtensionsPath", AppContext.BaseDirectory },
{ "CscToolExe", GetRunCscPath() }
};
}
private static string GetMSBuildExePath()
{
return Path.Combine(
AppContext.BaseDirectory,
s_msbuildExeName);
}
private static string GetRunCscPath()
{
var scriptExtension = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ".cmd" : ".sh";
return Path.Combine(AppContext.BaseDirectory, $"RunCsc{scriptExtension}");
}
}
}