Enabling creating packages with different names than target libraries
Addresses #2322
This commit is contained in:
parent
b9d6a0c911
commit
6a571e5b2a
3 changed files with 41 additions and 24 deletions
|
@ -75,7 +75,12 @@ namespace Microsoft.DotNet.Tools.Compiler
|
|||
PopulateDependencies(context);
|
||||
|
||||
var inputFolder = ArtifactPathsCalculator.InputPathForContext(context);
|
||||
var outputName = GetProjectOutputName(context.TargetFramework);
|
||||
|
||||
var compilationOptions = Project.GetCompilerOptions(context.TargetFramework, Configuration);
|
||||
var outputName = compilationOptions.OutputName;
|
||||
var outputExtension =
|
||||
context.TargetFramework.IsDesktop() && compilationOptions.EmitEntryPoint.GetValueOrDefault()
|
||||
? ".exe" : ".dll";
|
||||
|
||||
var resourceCultures = context.ProjectFile.Files.ResourceFiles
|
||||
.Select(resourceFile => ResourceUtility.GetResourceCultureName(resourceFile.Key))
|
||||
|
@ -88,13 +93,13 @@ namespace Microsoft.DotNet.Tools.Compiler
|
|||
continue;
|
||||
}
|
||||
|
||||
var resourceFilePath = Path.Combine(culture, $"{Project.Name}.resources.dll");
|
||||
var resourceFilePath = Path.Combine(culture, $"{outputName}.resources.dll");
|
||||
TryAddOutputFile(context, inputFolder, resourceFilePath);
|
||||
}
|
||||
|
||||
TryAddOutputFile(context, inputFolder, outputName);
|
||||
TryAddOutputFile(context, inputFolder, $"{Project.Name}.xml");
|
||||
TryAddOutputFile(context, inputFolder, $"{Project.Name}.runtimeconfig.json");
|
||||
TryAddOutputFile(context, inputFolder, outputName + outputExtension);
|
||||
TryAddOutputFile(context, inputFolder, $"{outputName}.xml");
|
||||
TryAddOutputFile(context, inputFolder, $"{outputName}.runtimeconfig.json");
|
||||
}
|
||||
|
||||
protected virtual bool GeneratePackage(string nupkg, List<DiagnosticMessage> packDiagnostics)
|
||||
|
@ -312,19 +317,6 @@ namespace Microsoft.DotNet.Tools.Compiler
|
|||
return $"{Project.Name}.{Project.Version}";
|
||||
}
|
||||
|
||||
private string GetProjectOutputName(NuGetFramework framework)
|
||||
{
|
||||
var compilationOptions = Project.GetCompilerOptions(framework, Configuration);
|
||||
var outputExtension = ".dll";
|
||||
|
||||
if (framework.IsDesktop() && compilationOptions.EmitEntryPoint.GetValueOrDefault())
|
||||
{
|
||||
outputExtension = ".exe";
|
||||
}
|
||||
|
||||
return Project.Name + outputExtension;
|
||||
}
|
||||
|
||||
private static string GetDefaultRootOutputPath(Project project, string outputOptionValue)
|
||||
{
|
||||
string rootOutputPath = string.Empty;
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace Microsoft.DotNet.Tools.Compiler
|
|||
{
|
||||
public class SymbolPackageGenerator: PackageGenerator
|
||||
{
|
||||
public SymbolPackageGenerator(Project project, string configuration, ArtifactPathsCalculator artifactPathsCalculator)
|
||||
public SymbolPackageGenerator(Project project, string configuration, ArtifactPathsCalculator artifactPathsCalculator)
|
||||
: base(project, configuration, artifactPathsCalculator)
|
||||
{
|
||||
}
|
||||
|
@ -26,8 +26,10 @@ namespace Microsoft.DotNet.Tools.Compiler
|
|||
base.ProcessContext(context);
|
||||
|
||||
var inputFolder = ArtifactPathsCalculator.InputPathForContext(context);
|
||||
TryAddOutputFile(context, inputFolder, $"{Project.Name}.pdb");
|
||||
TryAddOutputFile(context, inputFolder, $"{Project.Name}.mdb");
|
||||
var ouptutName = Project.GetCompilerOptions(context.TargetFramework, Configuration).OutputName;
|
||||
|
||||
TryAddOutputFile(context, inputFolder, $"{ouptutName}.pdb");
|
||||
TryAddOutputFile(context, inputFolder, $"{ouptutName}.mdb");
|
||||
}
|
||||
|
||||
protected override bool GeneratePackage(string nupkg, List<DiagnosticMessage> packDiagnostics)
|
||||
|
|
|
@ -59,7 +59,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Tests
|
|||
outputDir.Should().Exist();
|
||||
outputDir.Should().HaveFiles(new[] { "TestLibrary.1.0.0.nupkg", "TestLibrary.1.0.0.symbols.nupkg" });
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void SettingVersionSuffixFlag_ShouldStampAssemblyInfoInOutputAssemblyAndPackage()
|
||||
{
|
||||
|
@ -71,10 +71,10 @@ namespace Microsoft.DotNet.Tools.Compiler.Tests
|
|||
|
||||
var output = Path.Combine(testInstance.TestRoot, "bin", "Debug", DefaultFramework, "TestLibraryWithConfiguration.dll");
|
||||
var informationalVersion = PeReaderUtils.GetAssemblyAttributeValue(output, "AssemblyInformationalVersionAttribute");
|
||||
|
||||
|
||||
informationalVersion.Should().NotBeNull();
|
||||
informationalVersion.Should().BeEquivalentTo("1.0.0-85");
|
||||
|
||||
|
||||
var outputPackage = Path.Combine(testInstance.TestRoot, "bin", "Debug", "TestLibraryWithConfiguration.1.0.0-85.nupkg");
|
||||
File.Exists(outputPackage).Should().BeTrue(outputPackage);
|
||||
}
|
||||
|
@ -95,6 +95,29 @@ namespace Microsoft.DotNet.Tools.Compiler.Tests
|
|||
zip.Entries.Should().Contain(e => e.FullName == "lib/netstandardapp1.5/TestLibraryWithConfiguration.dll");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PackAddsCorrectFilesForProjectsWithOutputNameSpecified()
|
||||
{
|
||||
var testInstance =
|
||||
TestAssetsManager
|
||||
.CreateTestInstance("LibraryWithOutputAssemblyName")
|
||||
.WithLockFiles();
|
||||
|
||||
var cmd = new PackCommand(Path.Combine(testInstance.TestRoot, Project.FileName));
|
||||
cmd.Execute().Should().Pass();
|
||||
|
||||
var outputPackage = Path.Combine(testInstance.TestRoot, "bin", "Debug", "LibraryWithOutputAssemblyName.1.0.0.nupkg");
|
||||
File.Exists(outputPackage).Should().BeTrue(outputPackage);
|
||||
var zip = ZipFile.Open(outputPackage, ZipArchiveMode.Read);
|
||||
zip.Entries.Should().Contain(e => e.FullName == "lib/netstandardapp1.5/MyLibrary.dll");
|
||||
|
||||
var symbolsPackage = Path.Combine(testInstance.TestRoot, "bin", "Debug", "LibraryWithOutputAssemblyName.1.0.0.symbols.nupkg");
|
||||
File.Exists(symbolsPackage).Should().BeTrue(symbolsPackage);
|
||||
zip = ZipFile.Open(symbolsPackage, ZipArchiveMode.Read);
|
||||
zip.Entries.Should().Contain(e => e.FullName == "lib/netstandardapp1.5/MyLibrary.dll");
|
||||
zip.Entries.Should().Contain(e => e.FullName == "lib/netstandardapp1.5/MyLibrary.pdb");
|
||||
}
|
||||
|
||||
private void CopyProjectToTempDir(string projectDir, TempDirectory tempDir)
|
||||
{
|
||||
// copy all the files to temp dir
|
||||
|
|
Loading…
Add table
Reference in a new issue