From ce6ce3c49b2f552c77615fba56c7a931153a387c Mon Sep 17 00:00:00 2001 From: moozzyk Date: Thu, 17 Mar 2016 16:52:50 -0700 Subject: [PATCH] Folding ProjectFile.Name to compiler options --- src/Microsoft.DotNet.Compiler.Common/Executable.cs | 13 ++++--------- .../CompilationOutputFiles.cs | 4 +--- src/Microsoft.DotNet.ProjectModel/Project.cs | 9 ++++++++- .../RuntimeOutputFiles.cs | 6 ++---- .../commands/dotnet-compile/ManagedCompiler.cs | 7 +++---- .../commands/dotnet-publish/PublishCommand.cs | 2 +- 6 files changed, 19 insertions(+), 22 deletions(-) diff --git a/src/Microsoft.DotNet.Compiler.Common/Executable.cs b/src/Microsoft.DotNet.Compiler.Common/Executable.cs index 6e3012833..930450049 100644 --- a/src/Microsoft.DotNet.Compiler.Common/Executable.cs +++ b/src/Microsoft.DotNet.Compiler.Common/Executable.cs @@ -80,7 +80,7 @@ namespace Microsoft.Dotnet.Cli.Compiler.Common if (emitEntryPoint && !string.IsNullOrEmpty(_context.RuntimeIdentifier)) { // TODO: Pick a host based on the RID - CoreHost.CopyTo(_runtimeOutputPath, GetOutputName() + Constants.ExeSuffix); + CoreHost.CopyTo(_runtimeOutputPath, _compilerOptions.OutputName + Constants.ExeSuffix); } } @@ -145,7 +145,7 @@ namespace Microsoft.Dotnet.Cli.Compiler.Common } var runtimeConfigJsonFile = - Path.Combine(_runtimeOutputPath, GetOutputName() + FileNameSuffixes.RuntimeConfigJson); + Path.Combine(_runtimeOutputPath, _compilerOptions.OutputName + FileNameSuffixes.RuntimeConfigJson); using (var writer = new JsonTextWriter(new StreamWriter(File.Create(runtimeConfigJsonFile)))) { @@ -159,7 +159,7 @@ namespace Microsoft.Dotnet.Cli.Compiler.Common { Directory.CreateDirectory(_runtimeOutputPath); - var depsFilePath = Path.Combine(_runtimeOutputPath, GetOutputName() + FileNameSuffixes.Deps); + var depsFilePath = Path.Combine(_runtimeOutputPath, _compilerOptions.OutputName + FileNameSuffixes.Deps); File.WriteAllLines(depsFilePath, exporter .GetDependencies(LibraryType.Package) .SelectMany(GenerateLines)); @@ -176,7 +176,7 @@ namespace Microsoft.Dotnet.Cli.Compiler.Common runtime: _context.RuntimeIdentifier ?? string.Empty); var writer = new DependencyContextWriter(); - var depsJsonFilePath = Path.Combine(_runtimeOutputPath, GetOutputName() + FileNameSuffixes.DepsJson); + var depsJsonFilePath = Path.Combine(_runtimeOutputPath, _compilerOptions.OutputName + FileNameSuffixes.DepsJson); using (var fileStream = File.Create(depsJsonFilePath)) { writer.Write(dependencyContext, fileStream); @@ -212,11 +212,6 @@ namespace Microsoft.Dotnet.Cli.Compiler.Common } } - private string GetOutputName() - { - return _compilerOptions.OutputName ?? _context.ProjectFile.Name; - } - private static IEnumerable GenerateLines(LibraryExport export) { return GenerateLines(export, export.RuntimeAssemblies, "runtime") diff --git a/src/Microsoft.DotNet.ProjectModel/CompilationOutputFiles.cs b/src/Microsoft.DotNet.ProjectModel/CompilationOutputFiles.cs index aabbae873..ddfbf5b86 100644 --- a/src/Microsoft.DotNet.ProjectModel/CompilationOutputFiles.cs +++ b/src/Microsoft.DotNet.ProjectModel/CompilationOutputFiles.cs @@ -42,9 +42,7 @@ namespace Microsoft.DotNet.ProjectModel { var compilationOptions = Project.GetCompilerOptions(Framework, Configuration); - return Path.Combine( - BasePath, - (compilationOptions.OutputName ?? Project.Name) + OutputExtension); + return Path.Combine(BasePath, compilationOptions.OutputName + OutputExtension); } } diff --git a/src/Microsoft.DotNet.ProjectModel/Project.cs b/src/Microsoft.DotNet.ProjectModel/Project.cs index 5e187f55b..aba323351 100644 --- a/src/Microsoft.DotNet.ProjectModel/Project.cs +++ b/src/Microsoft.DotNet.ProjectModel/Project.cs @@ -108,7 +108,14 @@ namespace Microsoft.DotNet.ProjectModel var targetFrameworkOptions = targetFramework != null ? GetCompilerOptions(targetFramework) : null; // Combine all of the options - return CommonCompilerOptions.Combine(rootOptions, configurationOptions, targetFrameworkOptions); + var compilerOptions = CommonCompilerOptions.Combine(rootOptions, configurationOptions, targetFrameworkOptions); + + if (compilerOptions.OutputName == null) + { + compilerOptions.OutputName = Name; + } + + return compilerOptions; } public TargetFrameworkInformation GetTargetFramework(NuGetFramework targetFramework) diff --git a/src/Microsoft.DotNet.ProjectModel/RuntimeOutputFiles.cs b/src/Microsoft.DotNet.ProjectModel/RuntimeOutputFiles.cs index 7b5f2b355..0d1dab480 100644 --- a/src/Microsoft.DotNet.ProjectModel/RuntimeOutputFiles.cs +++ b/src/Microsoft.DotNet.ProjectModel/RuntimeOutputFiles.cs @@ -37,12 +37,10 @@ namespace Microsoft.DotNet.ProjectModel // The executable is a DLL in this case extension = FileNameSuffixes.DotNet.DynamicLib; } - + var compilationOptions = Project.GetCompilerOptions(Framework, Configuration); - return Path.Combine( - BasePath, - (compilationOptions.OutputName ?? Project.Name) + extension); + return Path.Combine(BasePath, compilationOptions.OutputName + extension); } } diff --git a/src/dotnet/commands/dotnet-compile/ManagedCompiler.cs b/src/dotnet/commands/dotnet-compile/ManagedCompiler.cs index 0c883c260..3177d61df 100644 --- a/src/dotnet/commands/dotnet-compile/ManagedCompiler.cs +++ b/src/dotnet/commands/dotnet-compile/ManagedCompiler.cs @@ -97,7 +97,7 @@ namespace Microsoft.DotNet.Tools.Compiler { var transformedResource = resourceFile.GetTransformedFile(intermediateOutputPath); var resourceName = ResourceManifestName.CreateManifestName( - Path.GetFileName(resourceFile.ResolvedPath), compilationOptions.OutputName ?? context.ProjectFile.Name); + Path.GetFileName(resourceFile.ResolvedPath), compilationOptions.OutputName); compilerArgs.Add($"--resource:\"{transformedResource}\",{resourceName}"); } @@ -120,14 +120,13 @@ namespace Microsoft.DotNet.Tools.Compiler context.RuntimeIdentifier ?? string.Empty); var writer = new DependencyContextWriter(); - var depsJsonFile = Path.Combine(intermediateOutputPath, - (compilationOptions.OutputName ?? context.ProjectFile.Name) + "dotnet-compile.deps.json"); + var depsJsonFile = Path.Combine(intermediateOutputPath, compilationOptions.OutputName + "dotnet-compile.deps.json"); using (var fileStream = File.Create(depsJsonFile)) { writer.Write(dependencyContext, fileStream); } - compilerArgs.Add($"--resource:\"{depsJsonFile}\",{compilationOptions.OutputName ?? context.ProjectFile.Name}.deps.json"); + compilerArgs.Add($"--resource:\"{depsJsonFile}\",{compilationOptions.OutputName}.deps.json"); } if (!AddNonCultureResources(context.ProjectFile, compilerArgs, intermediateOutputPath)) diff --git a/src/dotnet/commands/dotnet-publish/PublishCommand.cs b/src/dotnet/commands/dotnet-publish/PublishCommand.cs index b1e889962..10576af28 100644 --- a/src/dotnet/commands/dotnet-publish/PublishCommand.cs +++ b/src/dotnet/commands/dotnet-publish/PublishCommand.cs @@ -240,7 +240,7 @@ namespace Microsoft.DotNet.Tools.Publish } var outputBinaryName = binaryName.Equals(Constants.HostExecutableName) - ? ((compilationOptions.OutputName ?? context.ProjectFile.Name) + Constants.ExeSuffix) + ? compilationOptions.OutputName + Constants.ExeSuffix : binaryName; var outputBinaryPath = Path.Combine(outputPath, outputBinaryName);