Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the condition GenerateTargetFrameworkMonikerAttribute #9925

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

JaynieBai
Copy link
Member

Fixes #9840

Context

<Target Name="GenerateTargetFrameworkMonikerAttribute"
BeforeTargets="BeforeCompile"
DependsOnTargets="PrepareForBuild;GetReferenceAssemblyPaths"
Inputs="$(MSBuildToolsPath)\Microsoft.Common.targets"
Outputs="$(TargetFrameworkMonikerAssemblyAttributesPath)"
Condition="'@(Compile)' != '' and '$(GenerateTargetFrameworkAttribute)' == 'true'">
<!-- This is a file shared between projects so we have to take care to handle simultaneous writes (by ContinueOnError)
and a race between clean from one project and build from another (by not adding to FilesWritten so it doesn't clean) -->
<WriteLinesToFile
File="$(TargetFrameworkMonikerAssemblyAttributesPath)"
Lines="$(TargetFrameworkMonikerAssemblyAttributeText)"
Overwrite="true"
ContinueOnError="true"
Condition="'@(Compile)' != '' and '$(TargetFrameworkMonikerAssemblyAttributeText)' != ''"
/>
<ItemGroup Condition="'@(Compile)' != '' and '$(TargetFrameworkMonikerAssemblyAttributeText)' != ''">
<Compile Include="$(TargetFrameworkMonikerAssemblyAttributesPath)"/>
<!-- Do not put in FileWrites: this is a file shared between projects in %temp%, and cleaning it would create a race between projects during rebuild -->
</ItemGroup>
</Target>

The condition on the target doesn't match the condition on the WriteLinesToFile task. So get this
image

Changes Made

Add and '$(TargetFrameworkMonikerAssemblyAttributeText)' != '' to the Condition on the Target and removing the redundant conditions on tasks

@JaynieBai JaynieBai marked this pull request as draft March 27, 2024 02:01
@JaynieBai
Copy link
Member Author

Close this test PR

@JaynieBai JaynieBai closed this Apr 19, 2024
@JaynieBai JaynieBai reopened this Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Potential incrementality issue in GenerateTargetFrameworkMonikerAttribute
1 participant