Skip to content

Globbing and DependsUpon with resx files and custom tool doesn't quite work #2873

Closed

Description

@bradphelan

Here is a fun example of bad behaviour of globbing and the project system. I have

  <ItemGroup>
    <Compile Update="Properties\*.resx.cs">
      <DesignTime>True</DesignTime>
      <AutoGen>True</AutoGen>
      <DependentUpon>%(Filename)</DependentUpon>
    </Compile>
  </ItemGroup>

  <ItemGroup>
    <EmbeddedResource Update="Properties\*.resx">
      <Generator>I18NReactive</Generator>
      <LastGenOutput>%(Filename).resx.cs</LastGenOutput>
    </EmbeddedResource>
  </ItemGroup>

where I18NReactive is a custom single file generator I wrote. The globbing and dependencies work at first glance.

image

Then I right click and select run custom tool to regen the resx.cs file. And not only does it update the file it also updates my csproj file. 👎 so now it is

  <ItemGroup>
    <Compile Update="Properties\*.resx.cs">
      <DesignTime>True</DesignTime>
      <AutoGen>True</AutoGen>
      <DependentUpon>%(Filename)</DependentUpon>
    </Compile>
  </ItemGroup>

  <ItemGroup>
    <EmbeddedResource Update="Properties\*.resx">
      <Generator>I18NReactive</Generator>
      <LastGenOutput>%(Filename).resx.cs</LastGenOutput>
    </EmbeddedResource>
  </ItemGroup>

  <ItemGroup>
    <Compile Update="Properties\lang.resx.cs">
      <DesignTime>True</DesignTime>
      <AutoGen>True</AutoGen>
      <DependentUpon>lang.resx</DependentUpon>
    </Compile>
  </ItemGroup>

  <ItemGroup>
    <EmbeddedResource Update="Properties\lang.resx">
      <Generator>I18NReactive</Generator>
      <LastGenOutput>lang.resx.cs</LastGenOutput>
    </EmbeddedResource>
  </ItemGroup>

that's kinda wierd no?

I also tried

 <ItemGroup>
    <Compile Remove="Properties\*.resx.cs" />
    <Compile Include="Properties\*.resx.cs">
      <DesignTime>True</DesignTime>
      <AutoGen>True</AutoGen>
      <DependentUpon>%(Filename)</DependentUpon>
    </Compile>
  </ItemGroup>

  <ItemGroup>
    <EmbeddedResource Remove="Properties\*.resx" />
    <EmbeddedResource Include="Properties\*.resx">
      <Generator>I18NReactive</Generator>
      <LastGenOutput>%(Filename).resx.cs</LastGenOutput>
    </EmbeddedResource>
  </ItemGroup>

Activity

  1. added
    Feature-Project-File-Simplification
    on Oct 17, 2017
  2. added this to the 15.6 milestone on Oct 17, 2017
  3. Pilchie commented on Dec 22, 2017

    @Pilchie
    Member

    @jviau - would this be project-system, or core CPS?

  4. modified the milestones: 15.6, on Dec 22, 2017
  5. clairernovotny commented on Dec 22, 2017

    @clairernovotny

    It's nasty, but here's a glob that works for Resx/embedded resources:
    https://github.com/onovotny/MSBuildSdkExtras/blob/master/MSBuild.Sdk.Extras/build/MSBuild.Sdk.Extras.Common.targets#L14-L28

    I see the same stuff getting added to the project file when you run the tool.

  6. jviau commented on Feb 13, 2018

    @jviau
    Contributor

    This is CPS. I have identified the issue, single file generator is rewriting all property, causing us to expand them all. We will fix this soon.

  7. Pilchie commented on Feb 14, 2018

    @Pilchie
    Member

    Nice - @jviau is there an ID for the issue on the CPS side?

  8. Pilchie commented on Feb 14, 2018

    @Pilchie
    Member

    Great - closing as external then. If you can - it would be great to comment here on the expected release with the fix once it's merged.

  9. added
    Area-External-CPS
    on Feb 14, 2018
  10. added a commit that references this issue on Feb 17, 2018
  11. 2 remaining items

  12. added this to the 16.5 milestone on Dec 3, 2019
  13. added
    Feature-Project-File-Editing
    on Dec 3, 2019
  14. davkean commented on Dec 3, 2019

    @davkean
    Member

    @davidwengier We had a bunch of changes both in single file generators and editing since above - can we verify if this still exists? The internal bug was won't fix but we've had feedback here and dotnet/msbuild#2352 (comment).

  15. added
    Needs-CPS-work
    and removed
    Feature-Project-File-Editing
    on Dec 6, 2019
  16. SimonCropp commented on Dec 6, 2019

    @SimonCropp
    Contributor

    i also note that renaming a parent file, that has dependents globbed under it, results in those dependents being explicitly duplicated in the csproj. will the fix for this issue also resolve that?

  17. davkean commented on Dec 6, 2019

    @davkean
    Member

    @SimonCropp No, can you file a new one for that here?

  18. SimonCropp commented on Dec 6, 2019

    @SimonCropp
    Contributor
  19. davidwengier commented on Dec 10, 2019

    @davidwengier
    Member

    This has been fixed.

  20. added
    Resolution-Fixed
    on Dec 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Area-External-CPSFeature-Project-File-SimplificationNeeds-CPS-workResolution-Fixed

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions