dotnet / dotnet/msbuild

Generating strongly typed resource files requires non-intuitive addition of properties

Open
#4,751 32 comments 19 reactions 1 assignee Claimed by @rainersigwald View on GitHub
Area: Task: GenerateResource
Dominant language
C#
Stars
5.5k
Forks
1.5k
Avg merge
1d 8h
Merged PRs (30d)
141

Description

From https://github.com/microsoft/msbuild/issues/2272#issuecomment-532264659
cc @rainersigwald
### Steps to reproduce

```
git clone https://github.com/PowerShell/PSScriptanalyzer
rm global.json # so that the latest version (3.0) of the SDK is used and not 2.2
cd Engine
dotnet build # should work
rm Strings.Designer.cs
dotnet build # does not work
```
### Expected behavior
Build works

### Actual behavior
Build fails due to errors resulting from Strings.Designer.cs not being created.

It seems one needs to apply the following non-intuitive changes to the `Engine.csproj`:

```diff
-
-
- True
- True
- Strings.resx
-
-



- ResXFileCodeGenerator
+ MSBuild:Compile
- Strings.Designer.cs
+ $(IntermediateOutputPath)\Strings.Designer.cs
+ CSharp
+ Microsoft.Windows.PowerShell.ScriptAnalyzer
+ Strings

+
+
+ PrepareResources;$(CompileDependsOn)
+
```

The `StronglyTypedNamespace` is due to the following in the csproj: `Microsoft.Windows.PowerShell.ScriptAnalyzer`
However, having to supply all the other additional parameters seems unintuitive. I'd like to see a minimal solution for a csproj that also works with VS btw.

### Environment data
`msbuild /version` output:

OS info:

Windows 10 1809
.Net Core 3.0-rc1

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.