Add a auto-generated header to the assembly info file that is created on build
This commit is contained in:
parent
268dd603cc
commit
61281b4580
3 changed files with 6 additions and 4 deletions
|
@ -16,7 +16,7 @@ namespace Microsoft.DotNet.Cli.Compiler.Common
|
||||||
{
|
{
|
||||||
public class AssemblyInfoFileGenerator
|
public class AssemblyInfoFileGenerator
|
||||||
{
|
{
|
||||||
public static string Generate(AssemblyInfoOptions metadata, IEnumerable<string> sourceFiles)
|
public static string GenerateCSharp(AssemblyInfoOptions metadata, IEnumerable<string> sourceFiles)
|
||||||
{
|
{
|
||||||
var projectAttributes = GetProjectAttributes(metadata);
|
var projectAttributes = GetProjectAttributes(metadata);
|
||||||
|
|
||||||
|
@ -43,7 +43,8 @@ namespace Microsoft.DotNet.Cli.Compiler.Common
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return string.Join(Environment.NewLine, projectAttributes
|
string autoGeneratedHeader = "// <auto-generated> This file has been auto generated. </auto-generated>\r\n";
|
||||||
|
return autoGeneratedHeader + string.Join(Environment.NewLine, projectAttributes
|
||||||
.Where(projectAttribute => projectAttribute.Value != null && !existingAttributes.Contains(projectAttribute.Key))
|
.Where(projectAttribute => projectAttribute.Value != null && !existingAttributes.Contains(projectAttribute.Key))
|
||||||
.Select(projectAttribute => $"[assembly:{projectAttribute.Key.FullName}(\"{projectAttribute.Value}\")]"));
|
.Select(projectAttribute => $"[assembly:{projectAttribute.Key.FullName}(\"{projectAttribute.Value}\")]"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,7 +90,8 @@ namespace Microsoft.DotNet.Tools.Compiler.Csc
|
||||||
// Generate assembly info
|
// Generate assembly info
|
||||||
var assemblyInfo = Path.Combine(tempOutDir, $"dotnet-compile.assemblyinfo.cs");
|
var assemblyInfo = Path.Combine(tempOutDir, $"dotnet-compile.assemblyinfo.cs");
|
||||||
|
|
||||||
File.WriteAllText(assemblyInfo, AssemblyInfoFileGenerator.Generate(assemblyInfoOptions, sources));
|
File.WriteAllText(assemblyInfo, AssemblyInfoFileGenerator.GenerateCSharp(assemblyInfoOptions, sources));
|
||||||
|
|
||||||
allArgs.Add($"\"{assemblyInfo}\"");
|
allArgs.Add($"\"{assemblyInfo}\"");
|
||||||
|
|
||||||
if (outputName != null)
|
if (outputName != null)
|
||||||
|
|
|
@ -58,7 +58,7 @@ namespace Microsoft.DotNet.Tools.Resgen
|
||||||
|
|
||||||
compilation = compilation.AddSyntaxTrees(new[]
|
compilation = compilation.AddSyntaxTrees(new[]
|
||||||
{
|
{
|
||||||
CSharpSyntaxTree.ParseText(AssemblyInfoFileGenerator.Generate(metadata, Enumerable.Empty<string>()))
|
CSharpSyntaxTree.ParseText(AssemblyInfoFileGenerator.GenerateCSharp(metadata, Enumerable.Empty<string>()))
|
||||||
});
|
});
|
||||||
|
|
||||||
var result = compilation.Emit(outputStream, manifestResources: resourceDescriptions);
|
var result = compilation.Emit(outputStream, manifestResources: resourceDescriptions);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue