Migrate GenerateFileFromTemplate to Microsoft.DotNet.Build.Tasks.Templating#7403
Migrate GenerateFileFromTemplate to Microsoft.DotNet.Build.Tasks.Templating#7403
Conversation
dougbu
left a comment
There was a problem hiding this comment.
My comments are all nits but I would like to hear from @alexperovich and / or @markwilkie before we merge.
src/Microsoft.DotNet.Build.Tasks.Templating/GenerateFileFromTemplate.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Build.Tasks.Templating/GenerateFileFromTemplate.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Build.Tasks.Templating/GenerateFileFromTemplate.cs
Outdated
Show resolved
Hide resolved
|
/fyi @rainersigwald (re dotnet/msbuild#4018) @ericstj (re #204) @ilyas1974 and @ViktorHofer (re tail end of #135) |
|
@rainersigwald this migrationf from aspnet/BuildTools reminds me of a rather unrelated question: Why is the |
src/Microsoft.DotNet.Build.Tasks.Templating/GenerateFileFromTemplate.cs
Outdated
Show resolved
Hide resolved
It was needed there first. I am not opposed in principle to "promoting" it. |
|
Great to see progress on this 👍 Does one task justify an additional assembly and with it package? Why not add it to the Arcade.Sdk project instead? |
src/Microsoft.DotNet.Build.Tasks.Templating/build/Microsoft.DotNet.Build.Tasks.Templating.props
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Build.Tasks.Templating/build/Microsoft.DotNet.Build.Tasks.Templating.props
Outdated
Show resolved
Hide resolved
|
That's the implementation that we use in dotnet/runtime: https://github.com/dotnet/runtime/blob/main/src/tasks/installer.tasks/GenerateRunScript.cs which looks simpler. Wouldn't that suffice? |
|
@ViktorHofer it was mentioned that this task shouldn't be included in the SDK: #204 (comment) so we decided to create a task package instead. As for comparison between GenerateRunScript.cs, this task is more general and can be used to substitute a user specified set of properties instead of just the specific |
src/Microsoft.DotNet.Build.Tasks.Templating/GenerateFileFromTemplate.cs
Outdated
Show resolved
Hide resolved
ViktorHofer
left a comment
There was a problem hiding this comment.
LGTM. What about tests? :)
|
There were no tests in the original implementation, maybe we should not block on that in this PR and file followup to add tests? |
Sure, works for me. |
src/Microsoft.DotNet.Build.Tasks.Templating/Microsoft.DotNet.Build.Tasks.Templating.csproj
Show resolved
Hide resolved
src/Microsoft.DotNet.Build.Tasks.Templating/GenerateFileFromTemplate.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Build.Tasks.Templating/Microsoft.DotNet.Build.Tasks.Templating.csproj
Show resolved
Hide resolved
…tNet.Build.Tasks.Templating.props Co-authored-by: Viktor Hofer <viktor.hofer@microsoft.com>
Co-authored-by: Doug Bunting <6431421+dougbu@users.noreply.github.com> Co-authored-by: Rainer Sigwald <raines@microsoft.com> Co-authored-by: Viktor Hofer <viktor.hofer@microsoft.com>
76b2505 to
ceaa936
Compare
|
Hey all, I've addressed the style guidelines and other feedback. |
| @@ -0,0 +1,29 @@ | |||
| <!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. --> | |||
There was a problem hiding this comment.
/fyi @markwilkie four projects in this repo use a different header:
<!-- Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -->They should probably be made consistent.
|
This PR has been reviewed though I don't see any |
|
While I have no context on the code itself, the intent is good with me. Assuming the right testing has happened, I'm find w/ merging. |
| /// The destination for the generated file. | ||
| /// </summary> | ||
| [Required] | ||
| [Output] |
There was a problem hiding this comment.
This "Output" is not correct, it's an input parameter. It's not returned by this task.
There was a problem hiding this comment.
Looks like we use it as output here: https://github.com/dotnet/aspnetcore/blob/52eff90fbcfca39b7eb58baad597df6a99a542b0/src/ProjectTemplates/GenerateContent.targets#L45-L52.
There was a problem hiding this comment.
Though I think it may be more correct to set the value to the value escaped by https://github.com/aspnet/BuildTools/blame/main/src/Internal.AspNetCore.BuildTasks/GenerateFileFromTemplate.cs#L55.
We could probably also separate it out into a separate out parameter like ResolvedOutputPath or EscapedOutputPath but so far we haven't run into any issues in our builds due to this being an Output parameter so I would prefer if we don't block on this change and file followup issues to address.
There was a problem hiding this comment.
This path is never set by this code. Marking it output is incorrect, since it doesn't actually output anything. We should not be checking in new, incorrect, code.
|
🎉🎉🎉 |
…lating (#7403) Co-authored-by: Viktor Hofer <viktor.hofer@microsoft.com> Co-authored-by: Doug Bunting <6431421+dougbu@users.noreply.github.com> Co-authored-by: Rainer Sigwald <raines@microsoft.com>
…lating (#7403) Co-authored-by: Viktor Hofer <viktor.hofer@microsoft.com> Co-authored-by: Doug Bunting <6431421+dougbu@users.noreply.github.com> Co-authored-by: Rainer Sigwald <raines@microsoft.com>
…s.Templating (#7503) * Migrate GenerateFileFromTemplate to Microsoft.DotNet.Build.Tasks.Templating (#7403) Co-authored-by: Viktor Hofer <viktor.hofer@microsoft.com> Co-authored-by: Doug Bunting <6431421+dougbu@users.noreply.github.com> Co-authored-by: Rainer Sigwald <raines@microsoft.com> * Cherry-pick fixes * TFM update * Fix syntax for older SDKs * More syntax fixes Co-authored-by: John Luo <johluo@microsoft.com> Co-authored-by: Viktor Hofer <viktor.hofer@microsoft.com> Co-authored-by: Doug Bunting <6431421+dougbu@users.noreply.github.com> Co-authored-by: Rainer Sigwald <raines@microsoft.com>
…s.Templating (#7502) * Migrate GenerateFileFromTemplate to Microsoft.DotNet.Build.Tasks.Templating (#7403) Co-authored-by: Viktor Hofer <viktor.hofer@microsoft.com> Co-authored-by: Doug Bunting <6431421+dougbu@users.noreply.github.com> Co-authored-by: Rainer Sigwald <raines@microsoft.com> * 5.0 fixes * TFM update Co-authored-by: John Luo <johluo@microsoft.com> Co-authored-by: Viktor Hofer <viktor.hofer@microsoft.com> Co-authored-by: Doug Bunting <6431421+dougbu@users.noreply.github.com> Co-authored-by: Rainer Sigwald <raines@microsoft.com>
Fixes #204. This will need to be backported to 3.1 and 5.0 after approval