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
In certain scenarios, we get a error MSB4057: The target "GetTargetPath" does not exist in the project. due to the TF not properly being set on a project reference.
The build fails with proj2\proj2.csproj : error MSB4057: The target "GetTargetPath" does not exist in the project.
Analysis
The specific piece of logic which is failing to run is:
<AnnotatedProjectsCondition="'@(AnnotatedProjects)' == '%(Identity)' and '%(AnnotatedProjects.NearestTargetFramework)' != '' and '%(AnnotatedProjects.HasSingleTargetFramework)' != 'true'">
<SetTargetFramework>TargetFramework=%(AnnotatedProjects.NearestTargetFramework)</SetTargetFramework>
</AnnotatedProjects>
That translates the NearestTargetFramework computed by GetReferenceNearestTargetFrameworkTask to SetTargetFramework, which is used when executing on project references.
Oddly, I couldn't seem to get this to repro if:
Proj1 is an SDK-style project
The duplicated ProjectReference did not differ in case (I guess there's some case-sensitive deduplication somewhere?)
Also note that the /p:BuildProjectReferences=false just helps show off the error more easily. Without it, the TF is still not properly set so the project refernce is "fully" built instead of building only 1 TF. Furthermore, I believe in this case the referenced project's assembly isn't returned so isn't actually given to the referencing project's compiler, an obvious downstream problem.
Versions & Configurations
16.9.0-preview-21076-21+8ed151254 (but it repros for earlier versions too.)
The text was updated successfully, but these errors were encountered:
I have a repro when Proj1 is an SDK-style project.
And I didn't need case differences in Proj2 references, two duplicate entries was enough to reproduce the bug.
I can also confirm this behavior in an SDK-style project. In my scenario, sub-project 1 targets netstandard2.0 and net481 while sub-project 2, which has sub-project 1 as a dependency, targets net481.
And another thing that was important was to put the netframework target in TargetFrameworks first: <TargetFrameworks>net472;net8.0</TargetFrameworks>
instead of the other way around.
Issue Description
In certain scenarios, we get a
error MSB4057: The target "GetTargetPath" does not exist in the project.
due to the TF not properly being set on a project reference.Steps to Reproduce
Proj1\Proj1.csproj:
(Note the project references are differently-cased)
Proj2\Proj2.csproj:
Commands:
Expected Behavior
The build succeeds.
Actual Behavior
The build fails with
proj2\proj2.csproj : error MSB4057: The target "GetTargetPath" does not exist in the project.
Analysis
The specific piece of logic which is failing to run is:
That translates the
NearestTargetFramework
computed byGetReferenceNearestTargetFrameworkTask
toSetTargetFramework
, which is used when executing on project references.Oddly, I couldn't seem to get this to repro if:
ProjectReference
did not differ in case (I guess there's some case-sensitive deduplication somewhere?)Also note that the
/p:BuildProjectReferences=false
just helps show off the error more easily. Without it, the TF is still not properly set so the project refernce is "fully" built instead of building only 1 TF. Furthermore, I believe in this case the referenced project's assembly isn't returned so isn't actually given to the referencing project's compiler, an obvious downstream problem.Versions & Configurations
16.9.0-preview-21076-21+8ed151254 (but it repros for earlier versions too.)
The text was updated successfully, but these errors were encountered: