Skip to content

Commit a8b2080

Browse files
authored
Update typed resgen to opt-in only
This makes it more predictable and explicit, also avoids generating strongly-typed resource classes for locales (which don't need them).
1 parent 5e17ad6 commit a8b2080

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/Directory.Build.targets

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,19 +106,17 @@
106106
<RepositoryBranch Condition="'$(RepositoryBranch)' == '' and '$(BUDDY_EXECUTION_BRANCH)' != ''">$(BUDDY_EXECUTION_BRANCH)</RepositoryBranch>
107107
</PropertyGroup>
108108

109-
<PropertyGroup Condition="'$(EnableRexCodeGenerator)' == 'true'">
110-
<!-- VSCode/Razor compatibility -->
111-
<CoreCompileDependsOn>PrepareResources;$(CoreCompileDependsOn)</CoreCompileDependsOn>
109+
<PropertyGroup>
110+
<!-- Default to Just Works resources generation. See https://www.cazzulino.com/resources.html -->
111+
<CoreCompileDependsOn>CoreResGen;$(CoreCompileDependsOn)</CoreCompileDependsOn>
112112
</PropertyGroup>
113-
113+
114114
<ItemGroup>
115115
<!-- Consider the project out of date if any of these files changes -->
116116
<UpToDateCheck Include="@(None);@(Content);@(EmbeddedResource)" />
117-
<!-- We'll typically use ThisAssembly.Strings instead of the built-in resource manager codegen -->
118-
<EmbeddedResource Update="@(EmbeddedResource)" Generator="" Condition="'$(EnableRexCodeGenerator)' != 'true'" />
119-
<EmbeddedResource Update="@(EmbeddedResource)" Condition="'$(EnableRexCodeGenerator)' == 'true'">
117+
<!-- Opt-in to typed resource generation by setting custom tool to MSBuild:Compile -->
118+
<EmbeddedResource Update="@(EmbeddedResource -> WithMetadataValue('Generator', 'MSBuild:Compile'))" Type="Resx">
120119
<!-- Default to Just Works resources generation. See https://www.cazzulino.com/resources.html -->
121-
<Generator>MSBuild:Compile</Generator>
122120
<StronglyTypedFileName>$(IntermediateOutputPath)\$([MSBuild]::ValueOrDefault('%(RelativeDir)', '').Replace('\', '.').Replace('/', '.'))%(Filename).g$(DefaultLanguageSourceExtension)</StronglyTypedFileName>
123121
<StronglyTypedLanguage>$(Language)</StronglyTypedLanguage>
124122
<StronglyTypedNamespace Condition="'%(RelativeDir)' == ''">$(RootNamespace)</StronglyTypedNamespace>

0 commit comments

Comments
 (0)