CZEMacLeod / MSBuild.SDK.SystemWeb

This MSBuild SDK is designed to allow for the easy creation and use of SDK (shortform) projects targeting ASP.NET 4.x using System.Web.
MIT License
151 stars 8 forks source link

App_GlobalResources should be content instead of embedded resource #3

Closed TheJayMann closed 3 years ago

TheJayMann commented 3 years ago

According to https://github.com/dotnet/project-system/issues/2670#issuecomment-820581558, resource files in the App_GlobalResources folder only work if they are built as Content, and will not work correctly if processed as an EmbeddedResource. This rule could be applied to the sdk include files so that it doesn't have to be done manually for all projects which make use of App_GlobalResources. An example solution that should be able to be placed in the import files is given in the comment, and included below.

<ItemGroup>
  <EmbeddedResource Remove="App_GlobalResources\*.resx" />
  <Content Include="App_GlobalResources\*.resx">
    <Generator>GlobalResourceProxyGenerator</Generator>
    <LastGenOutput>%(Filename).Designer.cs</LastGenOutput>
  </Content>
  <Compile Update="App_GlobalResources\*.Designer.cs">
    <DesignTime>True</DesignTime>
    <AutoGen>True</AutoGen>
    <DependentUpon>$([System.Text.RegularExpressions.Regex]::Replace('%(Filename)', '\.Designer$', '')).resx</DependentUpon>
  </Compile>
  <Compile Update="App_GlobalResources\*.Designer.vb">
    <DesignTime>True</DesignTime>
    <AutoGen>True</AutoGen>
    <DependentUpon>$([System.Text.RegularExpressions.Regex]::Replace('%(Filename)', '\.Designer$', '')).resx</DependentUpon>
  </Compile>
</ItemGroup>

I augmented the example to also include Designer.vb files, though, given that I have not used VB in a fairly long time, I'm not certain how the designer files work in this situation.