Skip to content

Commit

Permalink
Update typed resgen to opt-in only
Browse files Browse the repository at this point in the history
This makes it more predictable and explicit, also avoids generating strongly-typed resource classes for locales (which don't need them).
  • Loading branch information
kzu authored Sep 24, 2024
1 parent 5e17ad6 commit a8b2080
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -106,19 +106,17 @@
<RepositoryBranch Condition="'$(RepositoryBranch)' == '' and '$(BUDDY_EXECUTION_BRANCH)' != ''">$(BUDDY_EXECUTION_BRANCH)</RepositoryBranch>
</PropertyGroup>

<PropertyGroup Condition="'$(EnableRexCodeGenerator)' == 'true'">
<!-- VSCode/Razor compatibility -->
<CoreCompileDependsOn>PrepareResources;$(CoreCompileDependsOn)</CoreCompileDependsOn>
<PropertyGroup>
<!-- Default to Just Works resources generation. See https://www.cazzulino.com/resources.html -->
<CoreCompileDependsOn>CoreResGen;$(CoreCompileDependsOn)</CoreCompileDependsOn>
</PropertyGroup>

<ItemGroup>
<!-- Consider the project out of date if any of these files changes -->
<UpToDateCheck Include="@(None);@(Content);@(EmbeddedResource)" />
<!-- We'll typically use ThisAssembly.Strings instead of the built-in resource manager codegen -->
<EmbeddedResource Update="@(EmbeddedResource)" Generator="" Condition="'$(EnableRexCodeGenerator)' != 'true'" />
<EmbeddedResource Update="@(EmbeddedResource)" Condition="'$(EnableRexCodeGenerator)' == 'true'">
<!-- Opt-in to typed resource generation by setting custom tool to MSBuild:Compile -->
<EmbeddedResource Update="@(EmbeddedResource -> WithMetadataValue('Generator', 'MSBuild:Compile'))" Type="Resx">
<!-- Default to Just Works resources generation. See https://www.cazzulino.com/resources.html -->
<Generator>MSBuild:Compile</Generator>
<StronglyTypedFileName>$(IntermediateOutputPath)\$([MSBuild]::ValueOrDefault('%(RelativeDir)', '').Replace('\', '.').Replace('/', '.'))%(Filename).g$(DefaultLanguageSourceExtension)</StronglyTypedFileName>
<StronglyTypedLanguage>$(Language)</StronglyTypedLanguage>
<StronglyTypedNamespace Condition="'%(RelativeDir)' == ''">$(RootNamespace)</StronglyTypedNamespace>
Expand Down

0 comments on commit a8b2080

Please sign in to comment.