Skip to content

Project file is modified unexpectedly when using single file generator #2352

Closed

Description

@sharwell

📝 I'm not sure where this bug lies, but @srivatsn suggested I start by posting it here.

Steps to reproduce

  1. Check out DotNetAnalyzers/AsyncUsageAnalyzers@aa124aa

  2. Open AsyncUsageAnalyzers.sln in Visual Studio 2017 15.3 Update 4

  3. Right click the AsyncUsageAnalyzers project → Edit AsyncUsageAnalyzers.csproj

  4. Open Directory.build.targets

  5. Modify the existing code which updates designer files to also set the DesignTime and AutoGen metadata:

    <Compile Update="**\*.Designer.cs">
      <DesignTime>True</DesignTime>
      <AutoGen>True</AutoGen>
      <DependentUpon>$([System.IO.Path]::ChangeExtension($([System.IO.Path]::GetFileNameWithoutExtension(%(Identity))), '.resx'))</DependentUpon>
    </Compile>
  6. Add the following lines to Directory.build.targets:

    <ItemGroup>
      <EmbeddedResource Update="**\*.resx">
        <Generator>ResXFileCodeGenerator</Generator>
        <LastGenOutput>%(Filename).Designer.cs</LastGenOutput>
      </EmbeddedResource>
    </ItemGroup>
  7. Save the changes to Directory.build.targets

Expected results

No changes are made to AsyncUsageAnalyzers.csproj.

Actual results

The following block is added to AsyncUsageAnalyzers.csproj:

<ItemGroup>
  <Compile Update="Helpers\HelpersResources.Designer.cs">
    <DesignTime>True</DesignTime>
    <AutoGen>True</AutoGen>
    <DependentUpon>HelpersResources.resx</DependentUpon>
  </Compile>
  <Compile Update="Naming\NamingResources.Designer.cs">
    <DesignTime>True</DesignTime>
    <AutoGen>True</AutoGen>
    <DependentUpon>NamingResources.resx</DependentUpon>
  </Compile>
  <Compile Update="Reliability\ReliabilityResources.Designer.cs">
    <DesignTime>True</DesignTime>
    <AutoGen>True</AutoGen>
    <DependentUpon>ReliabilityResources.resx</DependentUpon>
  </Compile>
  <Compile Update="Resources.Designer.cs">
    <DesignTime>True</DesignTime>
    <AutoGen>True</AutoGen>
    <DependentUpon>Resources.resx</DependentUpon>
  </Compile>
  <Compile Update="Usage\UsageResources.Designer.cs">
    <DesignTime>True</DesignTime>
    <AutoGen>True</AutoGen>
    <DependentUpon>UsageResources.resx</DependentUpon>
  </Compile>
</ItemGroup>

<ItemGroup>
  <EmbeddedResource Update="Helpers\HelpersResources.resx">
    <Generator>ResXFileCodeGenerator</Generator>
    <LastGenOutput>HelpersResources.Designer.cs</LastGenOutput>
  </EmbeddedResource>
  <EmbeddedResource Update="Naming\NamingResources.resx">
    <Generator>ResXFileCodeGenerator</Generator>
    <LastGenOutput>NamingResources.Designer.cs</LastGenOutput>
  </EmbeddedResource>
  <EmbeddedResource Update="Reliability\ReliabilityResources.resx">
    <Generator>ResXFileCodeGenerator</Generator>
    <LastGenOutput>ReliabilityResources.Designer.cs</LastGenOutput>
  </EmbeddedResource>
  <EmbeddedResource Update="Resources.resx">
    <Generator>ResXFileCodeGenerator</Generator>
    <LastGenOutput>Resources.Designer.cs</LastGenOutput>
  </EmbeddedResource>
  <EmbeddedResource Update="Usage\UsageResources.resx">
    <Generator>ResXFileCodeGenerator</Generator>
    <LastGenOutput>UsageResources.Designer.cs</LastGenOutput>
  </EmbeddedResource>
</ItemGroup>

Activity

  1. rainersigwald commented on Jul 26, 2017

    @rainersigwald
    Member

    Just tried this, and it appears to only happen when the new project system's "edit project file" window is open. Since that window does some trickery with multiple files and evaluation states for the project, I bet what we're seeing is torn state between the project instances resulting in CPS wanting to fix up the project file to match the observed state.

    It looks like that functionality has recently moved into CPS, so I'm moving this to internal bug: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/470015.

  2. ltrzesniewski commented on Jan 14, 2019

    @ltrzesniewski

    This happens all the time for me in VS 15.9.5, even if the project file edit window is closed, as soon as a single-file generator of any kind is involved from what I can tell.

    As I don't have access to that internal link, can you give a status update on this @rainersigwald? Thanks.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions