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

CSharpier.MSBuild runs once for each framework, can it be more efficient. #900

Closed
belav opened this issue May 20, 2023 · 2 comments
Closed
Labels
area:msbuild type:enhancement New feature or request
Milestone

Comments

@belav
Copy link
Owner

belav commented May 20, 2023

When building the project at https://github.com/belav/CSharpierTest
The output contains CSharpier formatting files 3 times, once for each target framework.

Can CSharpier.MSBuild be smart enough to only format files for one of the target frameworks?

@belav belav added area:msbuild type:enhancement New feature or request labels May 20, 2023
@adc-cjewett
Copy link

We had a similar issue and used this solution. Not sure if it's 100% applicable since we use a different BeforeTarget but figured I'd at least share the info.

  <!-- If the project is not multi-target then run it once for the project. -->
  <Target Name="SingleTargetPathFilterUpdate"
        BeforeTargets="PreBuildEvent"
        Condition="'$(Configuration)' == 'Debug' 
            and '$(TargetFramework)' != ''">
    <PathFilterUpdateTask ProjectFilePath="$(MSBuildProjectDirectory)\$(MSBuildProjectFile)" />
  </Target>
  
  <!-- If the project is multi-target then only run once per project. -->
  <Target Name="MultiTargetPathFilterUpdate" 
          BeforeTargets="DispatchToInnerBuilds" 
          Condition="'$(Configuration)' == 'Debug' 
            and '$(TargetFrameworks)' != ''">
    <PathFilterUpdateTask ProjectFilePath="$(MSBuildProjectDirectory)\$(MSBuildProjectFile)" />
  </Target>

@belav belav added this to the 0.25.0 milestone May 22, 2023
@belav
Copy link
Owner Author

belav commented May 22, 2023

Thanks @adc-cjewett, that helped me get to where I needed to go. It didn't quite work inside of a nuget package, but I was able to track down a workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:msbuild type:enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants