Add target to the Arcade SDK that substitutes template replacement markers to avoid hardcoded TFM values
- Dominant language
- C#
- Stars
- 729
- Forks
- 397
- Avg merge
- 3d 15m
- Merged PRs (30d)
- 149
Description
With using floating TFM properties (i.e. `NetCurrent`), hardcoded TFMs in props/targets files will cause build failures whenever these TFM properties get updated. This would show up during consumption or during the repository's testing. Example of such a hardcoded TFM value: https://github.com/dotnet/xliff-tasks/blob/d66a09c8b11e1235273c8e6cd946e5c8e247f189/src/XliffTasks/build/Microsoft.DotNet.XliffTasks.targets#L5-L6
I imagine that we could solve this by adding a substitution marker into the .targets file which then gets replaced with the actual value at build time. i.e.
Microsoft.DotNet.XliffTasks.targets:
```xml
$(MSBuildThisFileDirectory)..\tools\$$NetCurrent$$\
$(MSBuildThisFileDirectory)..\tools\$$NetFrameworkMinimum$$\
```
XliffTasks.csproj:
```xml
```
We should use the [`GenerateFileFromTempalte` msbuild task](https://github.com/dotnet/arcade/blob/d88d069e52925c468346e09a10a1534e68fc6dab/src/Microsoft.DotNet.Build.Tasks.Templating/src/GenerateFileFromTemplate.cs#L30C18-L30C43) that's already part of Arcade.
The target could pass in defaults, i.e. [the default TFM properties and values that are defined by the Arcade SDK](https://github.com/dotnet/arcade/blob/main/src/Microsoft.DotNet.Arcade.Sdk/tools/TargetFrameworkDefaults.props) with the option of adding custom values.
cc @mmitche @mthalman @MichaelSimons @ericstj
Contributor guide
Assessment
This issue has not been assessed yet.