Fix DevDiv 736427
When a user builds a 2.1 or 2.2 project with a 3.0 they can get an error due to invalid command line options from rzc. What happens is that the 3.0 tasks (which are a singleton) are talking to the 2.X build tool (which is NOT a singleton). Recently some changes were make to the 3.0 tasks which caused this bug because it did not properly accomodate downlevel versions of rzc. We have an integration test for this scenario for but the regression was not detected, so obviously something is wrong with the test setup. I'll investigate that separately.
This commit is contained in:
parent
321327f84b
commit
1aace2b6c7
|
|
@ -31,7 +31,7 @@ namespace Microsoft.AspNetCore.Razor.Tasks
|
|||
public ITaskItem[] Configuration { get; set; }
|
||||
|
||||
[Required]
|
||||
public ITaskItem[] Extensions { get; set; }
|
||||
public ITaskItem[] Extensions { get; set; }
|
||||
|
||||
[Required]
|
||||
public ITaskItem[] Sources { get; set; }
|
||||
|
|
@ -90,6 +90,14 @@ namespace Microsoft.AspNetCore.Razor.Tasks
|
|||
|
||||
builder.AppendLine(Command);
|
||||
|
||||
// We might be talking to a downlevel version of the command line tool, which doesn't
|
||||
// understand certain parameters. Assume 2.1 if we can't parse the version because 2.1
|
||||
// 2.2 are the releases that have command line tool delivered by a package.
|
||||
if (!System.Version.TryParse(Version, out var parsedVersion))
|
||||
{
|
||||
parsedVersion = new System.Version(2, 1);
|
||||
}
|
||||
|
||||
for (var i = 0; i < Sources.Length; i++)
|
||||
{
|
||||
var input = Sources[i];
|
||||
|
|
@ -103,11 +111,15 @@ namespace Microsoft.AspNetCore.Razor.Tasks
|
|||
var outputPath = Path.Combine(ProjectRoot, input.GetMetadata(GeneratedOutput));
|
||||
builder.AppendLine(outputPath);
|
||||
|
||||
var kind = input.GetMetadata(DocumentKind);
|
||||
if (!string.IsNullOrEmpty(kind))
|
||||
// Added in 3.0
|
||||
if (parsedVersion.Major >= 3)
|
||||
{
|
||||
builder.AppendLine("-k");
|
||||
builder.AppendLine(kind);
|
||||
var kind = input.GetMetadata(DocumentKind);
|
||||
if (!string.IsNullOrEmpty(kind))
|
||||
{
|
||||
builder.AppendLine("-k");
|
||||
builder.AppendLine(kind);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -123,7 +135,8 @@ namespace Microsoft.AspNetCore.Razor.Tasks
|
|||
builder.AppendLine("-c");
|
||||
builder.AppendLine(Configuration[0].GetMetadata(Identity));
|
||||
|
||||
if (GenerateDeclaration)
|
||||
// Added in 3.0
|
||||
if (parsedVersion.Major >= 3 && GenerateDeclaration)
|
||||
{
|
||||
builder.AppendLine("--generate-declaration");
|
||||
}
|
||||
|
|
@ -152,4 +165,4 @@ namespace Microsoft.AspNetCore.Razor.Tasks
|
|||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue