Cleanup all the Trims everywhere. csc is the only program which requires response files to have quotes.
additional cleanup
This commit is contained in:
parent
806e506368
commit
b1885eaa58
6 changed files with 31 additions and 40 deletions
|
@ -22,7 +22,7 @@ namespace Microsoft.DotNet.Cli.Compiler.Common
|
||||||
var existingAttributes = new List<Type>();
|
var existingAttributes = new List<Type>();
|
||||||
foreach (var sourceFile in sourceFiles)
|
foreach (var sourceFile in sourceFiles)
|
||||||
{
|
{
|
||||||
var tree = CSharpSyntaxTree.ParseText(File.ReadAllText(sourceFile.Trim('"')));
|
var tree = CSharpSyntaxTree.ParseText(File.ReadAllText(sourceFile));
|
||||||
var root = tree.GetRoot();
|
var root = tree.GetRoot();
|
||||||
|
|
||||||
// assembly attributes can be only on first level
|
// assembly attributes can be only on first level
|
||||||
|
|
|
@ -82,29 +82,33 @@ namespace Microsoft.DotNet.Tools.Compiler.Csc
|
||||||
return returnCode;
|
return returnCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
var translated = TranslateCommonOptions(commonOptions, outputName.Trim('"'));
|
var translated = TranslateCommonOptions(commonOptions, outputName);
|
||||||
|
|
||||||
var allArgs = new List<string>(translated);
|
var allArgs = new List<string>(translated);
|
||||||
allArgs.AddRange(GetDefaultOptions());
|
allArgs.AddRange(GetDefaultOptions());
|
||||||
|
|
||||||
// Generate assembly info
|
// Generate assembly info
|
||||||
var tempOutputStrippedSpaces = tempOutDir.Trim('"');
|
var assemblyInfo = Path.Combine(tempOutDir, $"dotnet-compile.assemblyinfo.cs");
|
||||||
var assemblyInfo = Path.Combine(tempOutputStrippedSpaces, $"dotnet-compile.assemblyinfo.cs");
|
|
||||||
|
|
||||||
File.WriteAllText(assemblyInfo, AssemblyInfoFileGenerator.Generate(assemblyInfoOptions, sources));
|
File.WriteAllText(assemblyInfo, AssemblyInfoFileGenerator.Generate(assemblyInfoOptions, sources));
|
||||||
allArgs.Add($"\"{assemblyInfo}\"");
|
allArgs.Add($"\"{assemblyInfo}\"");
|
||||||
|
|
||||||
if (outputName != null)
|
if (outputName != null)
|
||||||
{
|
{
|
||||||
allArgs.Add($"-out:\"{outputName.Trim('"')}\"");
|
allArgs.Add($"-out:\"{outputName}\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
allArgs.AddRange(analyzers.Select(a => $"-a:\"{a.Trim('"')}\""));
|
allArgs.AddRange(analyzers.Select(a => $"-a:\"{a}\""));
|
||||||
allArgs.AddRange(references.Select(r => $"-r:\"{r.Trim('"')}\""));
|
allArgs.AddRange(references.Select(r => $"-r:\"{r}\""));
|
||||||
allArgs.AddRange(resources.Select(resource => $"-resource:{resource}"));
|
|
||||||
allArgs.AddRange(sources.Select(s => $"\"{s.Trim('"')}\""));
|
|
||||||
|
|
||||||
var rsp = Path.Combine(tempOutputStrippedSpaces, "dotnet-compile-csc.rsp");
|
// Resource has two parts separated by a comma
|
||||||
|
// Only the first should be quoted. This is handled
|
||||||
|
// in dotnet-compile where the information is present.
|
||||||
|
allArgs.AddRange(resources.Select(resource => $"-resource:{resource}"));
|
||||||
|
|
||||||
|
allArgs.AddRange(sources.Select(s => $"\"{s}\""));
|
||||||
|
|
||||||
|
var rsp = Path.Combine(tempOutDir, "dotnet-compile-csc.rsp");
|
||||||
|
|
||||||
File.WriteAllLines(rsp, allArgs, Encoding.UTF8);
|
File.WriteAllLines(rsp, allArgs, Encoding.UTF8);
|
||||||
|
|
||||||
|
@ -204,7 +208,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Csc
|
||||||
|
|
||||||
if (options.GenerateXmlDocumentation == true)
|
if (options.GenerateXmlDocumentation == true)
|
||||||
{
|
{
|
||||||
commonArgs.Add($"-doc:\"{Path.ChangeExtension(outputName.Trim('"'), "xml")}\"");
|
commonArgs.Add($"-doc:{Path.ChangeExtension(outputName, "xml")}");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.EmitEntryPoint != true)
|
if (options.EmitEntryPoint != true)
|
||||||
|
|
|
@ -80,9 +80,6 @@ namespace Microsoft.DotNet.Tools.Compiler.Fsc
|
||||||
return returnCode;
|
return returnCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
outputName = outputName.Trim('"');
|
|
||||||
tempOutDir = tempOutDir.Trim('"');
|
|
||||||
|
|
||||||
var translated = TranslateCommonOptions(commonOptions, outputName);
|
var translated = TranslateCommonOptions(commonOptions, outputName);
|
||||||
|
|
||||||
var allArgs = new List<string>(translated);
|
var allArgs = new List<string>(translated);
|
||||||
|
@ -115,9 +112,9 @@ namespace Microsoft.DotNet.Tools.Compiler.Fsc
|
||||||
allArgs.Add("--targetprofile:netcore");
|
allArgs.Add("--targetprofile:netcore");
|
||||||
}
|
}
|
||||||
|
|
||||||
allArgs.AddRange(references.Select(r => $"-r:{r.Trim('"')}"));
|
allArgs.AddRange(references.Select(r => $"-r:{r}"));
|
||||||
allArgs.AddRange(resources.Select(resource => $"--resource:{resource.Trim('"')}"));
|
allArgs.AddRange(resources.Select(resource => $"--resource:{resource}"));
|
||||||
allArgs.AddRange(sources.Select(s => $"{s.Trim('"')}"));
|
allArgs.AddRange(sources.Select(s => $"{s}"));
|
||||||
|
|
||||||
var rsp = Path.Combine(tempOutDir, "dotnet-compile-fsc.rsp");
|
var rsp = Path.Combine(tempOutDir, "dotnet-compile-fsc.rsp");
|
||||||
File.WriteAllLines(rsp, allArgs, Encoding.UTF8);
|
File.WriteAllLines(rsp, allArgs, Encoding.UTF8);
|
||||||
|
|
|
@ -56,8 +56,8 @@ namespace Microsoft.DotNet.Tools.Compiler
|
||||||
{
|
{
|
||||||
var arguments = new[]
|
var arguments = new[]
|
||||||
{
|
{
|
||||||
$"\"{resgenFile.InputFile}\"",
|
$"{resgenFile.InputFile}",
|
||||||
$"-o:\"{resgenFile.OutputFile}\"",
|
$"-o:{resgenFile.OutputFile}",
|
||||||
$"-v:{project.Version.Version}"
|
$"-v:{project.Version.Version}"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ namespace Microsoft.DotNet.Tools.Compiler
|
||||||
string outputPath)
|
string outputPath)
|
||||||
{
|
{
|
||||||
var referencePaths = CompilerUtil.GetReferencePathsForCultureResgen(dependencies);
|
var referencePaths = CompilerUtil.GetReferencePathsForCultureResgen(dependencies);
|
||||||
var resgenReferenceArgs = referencePaths.Select(path => $"-r:\"{path}\"").ToList();
|
var resgenReferenceArgs = referencePaths.Select(path => $"-r:{path}").ToList();
|
||||||
var cultureResgenFiles = CompilerUtil.GetCultureResources(project, outputPath);
|
var cultureResgenFiles = CompilerUtil.GetCultureResources(project, outputPath);
|
||||||
|
|
||||||
foreach (var resgenFile in cultureResgenFiles)
|
foreach (var resgenFile in cultureResgenFiles)
|
||||||
|
@ -104,10 +104,10 @@ namespace Microsoft.DotNet.Tools.Compiler
|
||||||
var arguments = new List<string>();
|
var arguments = new List<string>();
|
||||||
|
|
||||||
arguments.AddRange(resgenReferenceArgs);
|
arguments.AddRange(resgenReferenceArgs);
|
||||||
arguments.Add($"-o:\"{resgenFile.OutputFile}\"");
|
arguments.Add($"-o:{resgenFile.OutputFile}");
|
||||||
arguments.Add($"-c:{resgenFile.Culture}");
|
arguments.Add($"-c:{resgenFile.Culture}");
|
||||||
arguments.Add($"-v:{project.Version.Version}");
|
arguments.Add($"-v:{project.Version.Version}");
|
||||||
arguments.AddRange(resgenFile.InputFileToMetadata.Select(fileToMetadata => $"\"{fileToMetadata.Key}\",{fileToMetadata.Value}"));
|
arguments.AddRange(resgenFile.InputFileToMetadata.Select(fileToMetadata => $"{fileToMetadata.Key},{fileToMetadata.Value}"));
|
||||||
var rsp = Path.Combine(intermediateOutputPath, $"dotnet-resgen.rsp");
|
var rsp = Path.Combine(intermediateOutputPath, $"dotnet-resgen.rsp");
|
||||||
File.WriteAllLines(rsp, arguments);
|
File.WriteAllLines(rsp, arguments);
|
||||||
|
|
||||||
|
|
|
@ -72,8 +72,8 @@ namespace Microsoft.DotNet.Tools.Compiler
|
||||||
// Assemble args
|
// Assemble args
|
||||||
var compilerArgs = new List<string>()
|
var compilerArgs = new List<string>()
|
||||||
{
|
{
|
||||||
$"--temp-output:\"{intermediateOutputPath}\"",
|
$"--temp-output:{intermediateOutputPath}",
|
||||||
$"--out:\"{outputName}\""
|
$"--out:{outputName}"
|
||||||
};
|
};
|
||||||
|
|
||||||
var compilationOptions = CompilerUtil.ResolveCompilationOptions(context, args.ConfigValue);
|
var compilationOptions = CompilerUtil.ResolveCompilationOptions(context, args.ConfigValue);
|
||||||
|
@ -90,15 +90,15 @@ namespace Microsoft.DotNet.Tools.Compiler
|
||||||
foreach (var dependency in dependencies)
|
foreach (var dependency in dependencies)
|
||||||
{
|
{
|
||||||
references.AddRange(dependency.CompilationAssemblies.Select(r => r.ResolvedPath));
|
references.AddRange(dependency.CompilationAssemblies.Select(r => r.ResolvedPath));
|
||||||
compilerArgs.AddRange(dependency.SourceReferences.Select(s => $"\"{s}\""));
|
compilerArgs.AddRange(dependency.SourceReferences.Select(s => $"{s}"));
|
||||||
|
|
||||||
// Add analyzer references
|
// Add analyzer references
|
||||||
compilerArgs.AddRange(dependency.AnalyzerReferences
|
compilerArgs.AddRange(dependency.AnalyzerReferences
|
||||||
.Where(a => a.AnalyzerLanguage == languageId)
|
.Where(a => a.AnalyzerLanguage == languageId)
|
||||||
.Select(a => $"--analyzer:\"{a.AssemblyPath}\""));
|
.Select(a => $"--analyzer:{a.AssemblyPath}"));
|
||||||
}
|
}
|
||||||
|
|
||||||
compilerArgs.AddRange(references.Select(r => $"--reference:\"{r}\""));
|
compilerArgs.AddRange(references.Select(r => $"--reference:{r}"));
|
||||||
|
|
||||||
if (compilationOptions.PreserveCompilationContext == true)
|
if (compilationOptions.PreserveCompilationContext == true)
|
||||||
{
|
{
|
||||||
|
@ -115,7 +115,7 @@ namespace Microsoft.DotNet.Tools.Compiler
|
||||||
writer.Write(dependencyContext, fileStream);
|
writer.Write(dependencyContext, fileStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
compilerArgs.Add($"--resource:\"{depsJsonFile}\",{context.ProjectFile.Name}.deps.json");
|
compilerArgs.Add($"--resource:{depsJsonFile},{context.ProjectFile.Name}.deps.json");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!AddNonCultureResources(context.ProjectFile, compilerArgs, intermediateOutputPath))
|
if (!AddNonCultureResources(context.ProjectFile, compilerArgs, intermediateOutputPath))
|
||||||
|
|
|
@ -20,13 +20,7 @@ namespace Microsoft.DotNet.Tools.Resgen
|
||||||
public int Execute()
|
public int Execute()
|
||||||
{
|
{
|
||||||
var inputResourceFiles = Args.Select(ParseInputFile).ToArray();
|
var inputResourceFiles = Args.Select(ParseInputFile).ToArray();
|
||||||
var outputResourceFile = ResourceFile.Create(OutputFileName.Trim('"'));
|
var outputResourceFile = ResourceFile.Create(OutputFileName);
|
||||||
|
|
||||||
var trimmedCompilationReferences = default(string[]);
|
|
||||||
if (CompilationReferences != null)
|
|
||||||
{
|
|
||||||
trimmedCompilationReferences = CompilationReferences.Select(r => r.Trim('"')).ToArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (outputResourceFile.Type)
|
switch (outputResourceFile.Type)
|
||||||
{
|
{
|
||||||
|
@ -43,7 +37,7 @@ namespace Microsoft.DotNet.Tools.Resgen
|
||||||
outputStream,
|
outputStream,
|
||||||
metadata,
|
metadata,
|
||||||
Path.GetFileNameWithoutExtension(outputResourceFile.File.Name),
|
Path.GetFileNameWithoutExtension(outputResourceFile.File.Name),
|
||||||
trimmedCompilationReferences
|
CompilationReferences.ToArray()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -82,10 +76,6 @@ namespace Microsoft.DotNet.Tools.Resgen
|
||||||
metadataName = arg;
|
metadataName = arg;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove surrounding quotes
|
|
||||||
name = name.Trim('"');
|
|
||||||
metadataName = metadataName.Trim('"');
|
|
||||||
|
|
||||||
return new ResourceSource(ResourceFile.Create(name), metadataName);
|
return new ResourceSource(ResourceFile.Create(name), metadataName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue