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

Design-time race condition with MyProject.GeneratedMSBuildEditorConfig.editorconfig #51768

Open
jeromelaban opened this issue Mar 10, 2021 · 3 comments

Comments

@jeromelaban
Copy link

Version Used: 16.9 or 16.10

Steps to Reproduce:

  1. Use a source generator that sets msbuild properties to be populated in the GeneratedMSBuildEditorConfig.editorconfig file, which detects the presence of design time builds (BuildingProject is false)
  2. Build the project and have the design-time builds run simultaneously

Expected Behavior:
Design-time builds don't interfere with the main build.

Actual Behavior:
The main build may fail because the BuildingProject is false where it should be try.

Additional information

This kind of optimization is useful to determine whether to avoid generating extended and expensive source during design-time. It looks like the GeneratedMSBuildEditorConfig.editorconfig is shared for both build types and can get mixed depending on the build type.

This issue is even more visible on vscode with omnisharp, where there may be even less synchronization between command line builds and design-time builds.

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Mar 10, 2021
@jinujoseph jinujoseph added Concept-Continuous Improvement New Feature - Source Generators Source Generators and removed untriaged Issues and PRs which have not yet been triaged by a lead labels Mar 11, 2021
@jinujoseph jinujoseph added this to the 16.10 milestone Mar 11, 2021
@chsienki
Copy link
Contributor

Related: OmniSharp/omnisharp-roslyn#2112

@jeromelaban
Copy link
Author

Here's a quick and dirty workaround:

  <Target Name="Roslyn51768Workaround" BeforeTargets="BeforeBuild">
       <CreateProperty Value="$(IntermediateOutputPath)$(MSBuildProjectName).d$(DesignTimeBuild)-b$(BuildingProject).GeneratedMSBuildEditorConfig.editorconfig">
            <Output
                TaskParameter="Value"
                PropertyName="GeneratedMSBuildEditorConfigFile" />
        </CreateProperty>
  </Target>

@jcouv jcouv modified the milestones: 17.1, 17.2 Mar 17, 2022
@jcouv jcouv modified the milestones: 17.2, 17.3 May 14, 2022
@jaredpar jaredpar modified the milestones: 17.3, Backlog Jun 30, 2022
@Youssef1313
Copy link
Member

Youssef1313 commented Jun 20, 2023

@chsienki Do you think the issue here is that simply the task inputs are not reflected in target inputs?

<Target Name="GenerateMSBuildEditorConfigFileCore"
Condition="'$(_GeneratedEditorConfigShouldRun)' == 'true'"
Outputs="$(GeneratedMSBuildEditorConfigFile)">

PropertyItems="@(_GeneratedEditorConfigProperty)"
MetadataItems="@(_GeneratedEditorConfigMetadata)"

So basically once the file is written, the target is seen as up to date and is incorrectly skipped?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants