dotnet / dotnet/arcade

Add target to the Arcade SDK that substitutes template replacement markers to avoid hardcoded TFM values

Open
#14,138 4 comments 1 reaction 0 assignees View on GitHub
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.