Skip to content

Migrate GenerateFileFromTemplate to Microsoft.DotNet.Build.Tasks.Templating#7403

Merged
JunTaoLuo merged 11 commits into
mainfrom
johluo/template
Jun 9, 2021
Merged

Migrate GenerateFileFromTemplate to Microsoft.DotNet.Build.Tasks.Templating#7403
JunTaoLuo merged 11 commits into
mainfrom
johluo/template

Conversation

@JunTaoLuo

Copy link
Copy Markdown

Fixes #204. This will need to be backported to 3.1 and 5.0 after approval

@JunTaoLuo
JunTaoLuo requested review from dougbu and markwilkie May 18, 2021 18:32

@dougbu dougbu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My comments are all nits but I would like to hear from @alexperovich and / or @markwilkie before we merge.

Comment thread src/Microsoft.DotNet.Build.Tasks.Templating/GenerateFileFromTemplate.cs Outdated
Comment thread src/Microsoft.DotNet.Build.Tasks.Templating/GenerateFileFromTemplate.cs Outdated
Comment thread src/Microsoft.DotNet.Build.Tasks.Templating/GenerateFileFromTemplate.cs Outdated
Comment thread src/Microsoft.DotNet.Build.Tasks.Templating/MSBuildListSplitter.cs
@dougbu
dougbu requested a review from alexperovich May 18, 2021 19:11
@dougbu

dougbu commented May 18, 2021

Copy link
Copy Markdown
Contributor

/fyi @rainersigwald (re dotnet/msbuild#4018) @ericstj (re #204) @ilyas1974 and @ViktorHofer (re tail end of #135)

@dougbu

dougbu commented May 18, 2021

Copy link
Copy Markdown
Contributor

@rainersigwald this migrationf from aspnet/BuildTools reminds me of a rather unrelated question: Why is the <JoinItems> task in the .NET SDK and not together with the more general msbuild tasks and targets❔ I'm reminded of the discrepancy when I reach for Remove with MatchOnMetadata (a poorly-documented and limited option) or difficult-to-grok task batching alternatives in projects that don't use that SDK.

Comment thread src/Microsoft.DotNet.Build.Tasks.Templating/GenerateFileFromTemplate.cs Outdated
@rainersigwald

Copy link
Copy Markdown
Member

Why is the <JoinItems> task in the .NET SDK and not together with the more general msbuild tasks and targets❔

It was needed there first. I am not opposed in principle to "promoting" it.

@ViktorHofer

Copy link
Copy Markdown
Member

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?

@ViktorHofer

Copy link
Copy Markdown
Member

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?

@JunTaoLuo

Copy link
Copy Markdown
Author

@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 [[RunCommands]] and [[EchoRunCommands]]

Comment thread src/Microsoft.DotNet.Build.Tasks.Templating/GenerateFileFromTemplate.cs Outdated

@ViktorHofer ViktorHofer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. What about tests? :)

@JunTaoLuo

Copy link
Copy Markdown
Author

There were no tests in the original implementation, maybe we should not block on that in this PR and file followup to add tests?

@ViktorHofer

Copy link
Copy Markdown
Member

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.

Comment thread src/Microsoft.DotNet.Build.Tasks.Templating/GenerateFileFromTemplate.cs Outdated
John Luo and others added 8 commits May 29, 2021 00:08
…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>
@JunTaoLuo

Copy link
Copy Markdown
Author

Hey all, I've addressed the style guidelines and other feedback.

Comment thread src/Microsoft.DotNet.Build.Tasks.Templating/MSBuildListSplitter.cs
@@ -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. -->

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/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.

@JunTaoLuo
JunTaoLuo requested a review from alexperovich June 1, 2021 06:03
@dougbu

dougbu commented Jun 3, 2021

Copy link
Copy Markdown
Contributor

This PR has been reviewed though I don't see any :shipit:s from Core-Eng folks. Unless I hear different before later tonight, I'll merge. Please sing out w/ objections if you have any.

@markwilkie

Copy link
Copy Markdown
Contributor

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]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This "Output" is not correct, it's an input parameter. It's not returned by this task.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@JunTaoLuo JunTaoLuo changed the title Migrate GenerateTemplateFromFile to Microsoft.DotNet.Build.Tasks.Templating Migrate GenerateFileFromTemplate to Microsoft.DotNet.Build.Tasks.Templating Jun 8, 2021
@JunTaoLuo
JunTaoLuo merged commit e81d8c9 into main Jun 9, 2021
@JunTaoLuo
JunTaoLuo deleted the johluo/template branch June 9, 2021 20:49
@ViktorHofer

Copy link
Copy Markdown
Member

🎉🎉🎉

JunTaoLuo pushed a commit that referenced this pull request Jun 10, 2021
…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>
JunTaoLuo pushed a commit that referenced this pull request Jun 10, 2021
…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>
markwilkie pushed a commit that referenced this pull request Oct 5, 2021
…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>
markwilkie pushed a commit that referenced this pull request Oct 5, 2021
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Source file pre-processing

8 participants