MSBuildSdkExtras
MSBuildSdkExtras copied to clipboard
Slight incompatibility with the old MSBuild way of doing resources
If you have an old WinForms project and add a space to your class name, it gets turned into an underscore so you would have for instance Test Class.cs
containing Test_Class
.
With this SDK (which saved our hides btw, it's amazing!) this behavior is mostly retained, however in the automatically-generated code's ResourceManager property getter there's a line that looks somewhat like this:
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MyNamespace.Test ClassResources", typeof(Test_ClassResources).Assembly);
And the space/underscore mismatch eventually leads to a runtime exception.
I did the trivial fix, which is to simply rename the class, but thought I'd report this as a small piece of incompatibility compared to old WinForms csprojs.
Interesting… two questions
- What version of the .NET SDK Core were you using? (3.0 preview or 2.x)?
- Were you using the Extras (As WinForms is supported directly by 3.x)
What are the exact repro steps?
This seems like a bug somewhere in VS though @davkean, do you know where this bug should go?
Hi, I'm using 2.1, most of my csprojs are using the Microsoft SDK, but the WinForms ones are using Extras.
Repro steps: make an old .NET framework Winforms project, add a new form that has a space in its name, manually edit the csproj to be an SDK-style csproj, build, run, observe exception. Here's a snippet of how my csproj looks.
<Project Sdk="MSBuild.Sdk.Extras">
<ItemGroup>
<Reference Include="System.Management" />
<Reference Include="System.Windows.Forms" />
</ItemGroup>
<ItemGroup>
<Compile Update="Test Class.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Test Class.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Test Class.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Test Class.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
</Project>
I'm going to close this as WinForms/WPF issues should be in the main SDK at this point for 3.0.