2016-01-20 15:41:46 -08:00
|
|
|
|
// 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.IO;
|
|
|
|
|
using NuGet.Frameworks;
|
|
|
|
|
|
|
|
|
|
namespace Microsoft.DotNet.ProjectModel
|
|
|
|
|
{
|
|
|
|
|
public class OutputPathCalculator
|
|
|
|
|
{
|
2016-01-21 15:01:21 -08:00
|
|
|
|
private const string ObjDirectoryName = "obj";
|
|
|
|
|
|
2016-01-20 15:41:46 -08:00
|
|
|
|
private readonly ProjectContext _project;
|
|
|
|
|
|
2016-01-21 15:01:21 -08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Unaltered output path. Either what is passed in in the constructor, or the project directory.
|
|
|
|
|
/// </summary>
|
|
|
|
|
private string BaseOutputPath { get; }
|
|
|
|
|
|
|
|
|
|
public string BaseCompilationOutputPath { get; }
|
2016-01-20 15:41:46 -08:00
|
|
|
|
|
|
|
|
|
public OutputPathCalculator(
|
|
|
|
|
ProjectContext project,
|
2016-01-21 15:01:21 -08:00
|
|
|
|
string baseOutputPath)
|
2016-01-20 15:41:46 -08:00
|
|
|
|
{
|
|
|
|
|
_project = project;
|
2016-01-21 15:01:21 -08:00
|
|
|
|
|
|
|
|
|
BaseOutputPath = string.IsNullOrWhiteSpace(baseOutputPath) ? _project.ProjectDirectory : baseOutputPath;
|
|
|
|
|
|
|
|
|
|
BaseCompilationOutputPath = string.IsNullOrWhiteSpace(baseOutputPath)
|
2016-01-20 15:41:46 -08:00
|
|
|
|
? Path.Combine(_project.ProjectDirectory, DirectoryNames.Bin)
|
2016-01-21 15:01:21 -08:00
|
|
|
|
: baseOutputPath;
|
2016-01-20 15:41:46 -08:00
|
|
|
|
}
|
|
|
|
|
|
2016-01-21 15:01:21 -08:00
|
|
|
|
public string GetCompilationOutputPath(string buildConfiguration)
|
2016-01-20 15:41:46 -08:00
|
|
|
|
{
|
|
|
|
|
var outDir = Path.Combine(
|
2016-01-21 15:01:21 -08:00
|
|
|
|
BaseCompilationOutputPath,
|
2016-01-20 15:41:46 -08:00
|
|
|
|
buildConfiguration,
|
|
|
|
|
_project.TargetFramework.GetTwoDigitShortFolderName());
|
|
|
|
|
|
|
|
|
|
return outDir;
|
|
|
|
|
}
|
2016-01-21 15:01:21 -08:00
|
|
|
|
|
|
|
|
|
public string GetIntermediateOutputPath(string buildConfiguration, string intermediateOutputValue)
|
|
|
|
|
{
|
|
|
|
|
string intermediateOutputPath;
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(intermediateOutputValue))
|
|
|
|
|
{
|
|
|
|
|
intermediateOutputPath = Path.Combine(
|
|
|
|
|
BaseOutputPath,
|
|
|
|
|
ObjDirectoryName,
|
|
|
|
|
buildConfiguration,
|
|
|
|
|
_project.TargetFramework.GetTwoDigitShortFolderName());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
intermediateOutputPath = intermediateOutputValue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return intermediateOutputPath;
|
|
|
|
|
}
|
2016-01-20 15:41:46 -08:00
|
|
|
|
}
|
|
|
|
|
}
|