You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Question] Why test libraries that target single TFM use TargetFrameworkS (plural)? #47155
Very often when I try to run all tests without specifying TFM, I get the following error:
C:\Projects\runtime\src\libraries\System.Diagnostics.TraceSource\tests> dotnet run -c Release
Unable to run your project
Your project targets multiple frameworks. Specify which framework to run using '--framework'.
Can $(NetCoreAppCurrent) be more than one moniker?
Is there anything that stops us from applying the following change to all test projects?
@Anipik hit this limitation when implementing the config system. At least partially it was due to derived properties which were used in project body.
Regardless it wasn’t an intentional limitation. I think we should be able to do anything the normal SDK permits.
As @ericstj pointed out we rely on tfm being set globally(not in csproj) to set some of custom properties like TargetsWindows. We removed a lot of derived props like outpathPath from props to targets file.
IIRC the only obstacle currently against are the Targets* props being set before the csproj is loaded
I remembered another thing here that's challenging: nuget's conditions in props and targets. At the time those generated props/targets are imported we need to make sure the right value for $(TargetFramework) is set. IIRC this wasn't always the case for a project that just sets TargetFramework. Stuff has changed since then so it might be working now.
With dotnet/arcade#8377 it will be possible to change projects which don't multi-target and aren't RID specific (i.e. $(NetCoreAppCurrent) but not $(NetCoreAppCurrent)-Linux) to use TargetFramework instead of TargetFrameworks. That will make the build noticeably faster as well.
I tested my change with the ref projects so I would switch them over first and afterwards address the remaining projects in the libs tree.
Activity
ViktorHofer commentedon Jan 19, 2021
cc @ericstj. I don't remember the exact reason for that limitation anymore
ericstj commentedon Jan 19, 2021
@Anipik hit this limitation when implementing the config system. At least partially it was due to derived properties which were used in project body.
Regardless it wasn’t an intentional limitation. I think we should be able to do anything the normal SDK permits.
Anipik commentedon Jan 19, 2021
As @ericstj pointed out we rely on tfm being set globally(not in csproj) to set some of custom properties like TargetsWindows. We removed a lot of derived props like outpathPath from props to targets file.
IIRC the only obstacle currently against are the Targets* props being set before the csproj is loaded
adamsitnik commentedon Jan 20, 2021
Thank you all!
Since it looks that it can't be changed, I am going to close the issue.
ViktorHofer commentedon Jan 20, 2021
It definitely can be changed. Let's keep this issue open to track it.
ericstj commentedon Jan 20, 2021
I remembered another thing here that's challenging: nuget's conditions in props and targets. At the time those generated props/targets are imported we need to make sure the right value for
$(TargetFramework)is set. IIRC this wasn't always the case for a project that just setsTargetFramework. Stuff has changed since then so it might be working now.ViktorHofer commentedon Jan 22, 2022
With dotnet/arcade#8377 it will be possible to change projects which don't multi-target and aren't RID specific (i.e.
$(NetCoreAppCurrent)but not$(NetCoreAppCurrent)-Linux) to useTargetFrameworkinstead ofTargetFrameworks. That will make the build noticeably faster as well.I tested my change with the ref projects so I would switch them over first and afterwards address the remaining projects in the libs tree.
ViktorHofer commentedon May 10, 2022
This was fixed with #64500 and #64000.