Skip to content

Commit 847b146

Browse files
authored
Generate strongly typed resources as part of build (#1855)
* first working version * cleanup * apply change to rules project as well
1 parent af02e80 commit 847b146

File tree

4 files changed

+30
-4033
lines changed

4 files changed

+30
-4033
lines changed

Engine/Engine.csproj

+15-9
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,26 @@
4848
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
4949
</ItemGroup>
5050

51-
<ItemGroup>
52-
<Compile Update="Strings.Designer.cs">
53-
<DesignTime>True</DesignTime>
54-
<AutoGen>True</AutoGen>
55-
<DependentUpon>Strings.resx</DependentUpon>
56-
</Compile>
57-
</ItemGroup>
58-
51+
<!--
52+
This ItemGroup and PropertyGroup block is required for resource generation to work for
53+
.NET CLI, Visual Studio and VS-Code: https://github.com/dotnet/msbuild/issues/4751
54+
-->
5955
<ItemGroup>
6056
<EmbeddedResource Update="Strings.resx">
61-
<Generator>ResXFileCodeGenerator</Generator>
57+
<!-- Tell Visual Studio that MSBuild will do the generation and run a build if resx file changes. -->
58+
<Generator>MSBuild:Compile</Generator>
6259
<LastGenOutput>Strings.Designer.cs</LastGenOutput>
60+
<StronglyTypedFileName>$(IntermediateOutputPath)\Strings.Designer.cs</StronglyTypedFileName>
61+
<StronglyTypedLanguage>CSharp</StronglyTypedLanguage>
62+
<StronglyTypedNamespace>Microsoft.Windows.PowerShell.ScriptAnalyzer</StronglyTypedNamespace>
63+
<StronglyTypedClassName>Strings</StronglyTypedClassName>
6364
</EmbeddedResource>
6465
</ItemGroup>
66+
<!-- For VS Code/OmniSharp support, ensure that CoreResGen runs before CoreCompile -->
67+
<PropertyGroup>
68+
<CoreCompileDependsOn>PrepareResources;$(CompileDependsOn)</CoreCompileDependsOn>
69+
</PropertyGroup>
70+
6571

6672
<ItemGroup Condition="'$(TargetFramework)' == 'net6'">
6773
<PackageReference Include="System.Management.Automation" Version="7.0.11" />

0 commit comments

Comments
 (0)