Sdk parses TargetFramework into TargetFrameworkIdentifier, TargetFrameworkVersion and TargetFrameworkMoniker. A bunch of sdk and msbuild targets depends on correct values of these derived properties. The parsing fails if TargetFramework is not a defined value.
The TargetFramework parsing is done https://github.com/dotnet/sdk/blob/master/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.TargetFrameworkInference.targets#L47
This file automatically gets imported just after the .csproj by the sdk.
When we use custom Target Framework, we need to change the value of tfm to some already defined value before this parsing evaluation. Otherwise, it will result in Unsupported TargetFramework Error while running targets.
There are 2 work arounds that we use to address this:-
The ask here is to provide a hook to do this parsing(either of just tfm or both tfm and the derived props) before the sdk parses the tfm.
cc @ericstj @ViktorHofer
The hook would look like some conditional import of a targets files based on some convention (property / name / or otherwise as deemed appropriate).
@sfoslund Here's another issue you could tackle.
Why not provide a hook for importing build files before the contents of the SDK targets?
Here: Before BeforeCommon*.targets
and
Here: Before/After LanguageTargets
and
Here: after NuGet's Pack.targets
Those 4 are the most critical points a dev would need to inject the build files to customize their build.
Most helpful comment
Why not provide a hook for importing build files before the contents of the SDK targets?
Here: Before
BeforeCommon*.targetsand
Here: Before/After
LanguageTargetsand
Here: after NuGet's
Pack.targetsThose 4 are the most critical points a dev would need to inject the build files to customize their build.