Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AVRO-3673: improve msbuild task output #2101

Closed

Conversation

Freds72AtWork
Copy link

What is the purpose of the change

Improve upon #1966 to allow build task chaining

Verifying this change

This change added tests and can be verified by running the C# based unit tests.

Documentation

Does this pull request introduce a new feature? (yes)
If yes, how is the feature documented? (sample in README.md)

limitations under the License.
-->
<Project>
<UsingTask TaskName="Avro.msbuild.AvroGenTask" AssemblyFile="$(MSBuildThisFileDirectory)..\tasks\$(TargetFramework)\Avro.msbuild.dll" />
Copy link
Contributor

Choose a reason for hiding this comment

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

Please don't use $(TargetFramework) in the AssemblyFile parameter.

This is apparently included in the Apache.Avro.MSBuild package and imported by projects that reference the package. $(TargetFramework) is wrong for these reasons:

  • If my project targets net6.0 but is built using MSBuild.exe on .NET Framework, then the MSBuild process cannot load an Avro.msbuild.dll that was built for net6.0. It needs an Avro.msbuild.dll that was built for .NET Framework or .NET Standard 2.0.
  • If my project targets net45, then the UsingTask won't find Avro.msbuild.dll because there is no tasks\net45 directory in the package.
  • If my project has multiple target frameworks, then I want to run AvroGenTask just once in the crosstargeting build in which $(TargetFramework) is empty, rather than separately for each target framework; the generated files should be identical anyway and this lets the target-framework-specific builds run in parallel without trying to write the same files.
  • TargetFramework might be a custom alias that my project maps to some standard TargetFrameworkIdentifier and TargetFrameworkVersion. Treat TargetFramework(s) values as aliases NuGet/Home#5154

It would be easiest would be to always use netstandard2.0 in AssemblyFile. Alternatively, add conditions on $(MSBuildRuntimeType) and $(MSBuildVersion).

Copy link
Contributor

Choose a reason for hiding this comment

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

OTOH, this props file wouldn't even be imported in the crosstargeting build, because it is packed with PackagePath="build\" rather than PackagePath="buildMultiTargeting\".

Copy link
Contributor

Choose a reason for hiding this comment

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

Re using $(MSBuildVersion), the idea is that although MSBuild provides neither a built-in property nor a property function for getting the version of .NET on which MSBuild is running, each version of MSBuild on .NET requires some minimum version of .NET, so if $(MSBuildVersion) shows you have that version of MSBuild, then you can assume it can load assemblies built for the corresponding version of .NET. But I don't really see what advantage this would have over always using netstandard2.0.

Copy link
Author

Choose a reason for hiding this comment

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

understood - pushed change

@zcsizmadia
Copy link
Contributor

Why is a new PR needed to improve an existing PR?

@Freds72AtWork
Copy link
Author

Freds72AtWork commented Feb 16, 2023

Why is a new PR needed to improve an existing PR?

Not the same author - so needed to fetch zcsizmadia:revive-avro-msbuild branch to publish my own changes?

@zcsizmadia
Copy link
Contributor

The impovement PR should be a PR into the original PR'a branch it is extending instead of avro:master.

@Freds72AtWork
Copy link
Author

Freds72AtWork commented Feb 16, 2023

so kill this PR and submit to your branch?

(actually I already did - I was not sure how active https://github.com/zcsizmadia/avro was. See: https://github.com/zcsizmadia/avro/pull/1)

@zcsizmadia
Copy link
Contributor

Yes. This PR will become automatically a multi-author PR, so you your commits will be credited to you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants