You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
From @NeilMacMullen on Friday, January 3, 2025 3:39:17 PM
Describe the bug
I'm not sure if this is a bug but it's certainly unexpected behaviour and caused me to waste a few hours yesterday....
dotnet build appears to use the casing of the csproj file specified in the command rather than the actual casing in the file-system. The practical impact of this is that the default-namespace for embedded resources is then incorrect and since GetManifestResourceStream is case-sensitive, applications can fail depending upon what casing was used when specifying dotnet build or dotnet publish
To Reproduce
The attached zip file contains a minimal example but the repro case is trivial...
create a simple console application whose name is a mixture of upper and lower case (e.g. MyApp)
Build the application with expected casing of the project file then all lower-case...
➜ rm -r -force bin ;rm -r -force obj; dotnet build .\MyApp.csproj;.\bin\Debug\net9.0\myapp.exe
Restore complete (0.2s)
You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy
MyApp succeeded (0.2s) → bin\Debug\net9.0\MyApp.dll
Build succeeded in 0.7s
embedded resource 'MyApp.testData.txt'
➜ rm -r -force bin ;rm -r -force obj; dotnet build .\myapp.csproj;.\bin\Debug\net9.0\myapp.exe
Restore complete (0.2s)
You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy
myapp succeeded (0.2s) → bin\Debug\net9.0\myapp.dll
Build succeeded in 0.7s
embedded resource 'myapp.testData.txt'
Note the difference in output - the resource path uses the casing specified in the build line.
Somewhat unexpectedly, dotnet run manages to use the correct casing...
➜ rm -r -force bin ;rm -r -force obj; dotnet run .\myapp.csproj
embedded resource 'MyApp.testData.txt'
So my suspicion is that there's some missing normalization in MSBuild itself that could/should be done here. I think it's reasonable to expect the name of the file to be its on-disk name. @JanKrivanek / @rainersigwald any objections to moving this to dotnet/msbuild?
Issue moved from dotnet/sdk#45701
From @NeilMacMullen on Friday, January 3, 2025 3:39:17 PM
Describe the bug
I'm not sure if this is a bug but it's certainly unexpected behaviour and caused me to waste a few hours yesterday....
dotnet build
appears to use the casing of the csproj file specified in the command rather than the actual casing in the file-system. The practical impact of this is that the default-namespace for embedded resources is then incorrect and since GetManifestResourceStream is case-sensitive, applications can fail depending upon what casing was used when specifyingdotnet build
ordotnet publish
To Reproduce
The attached zip file contains a minimal example but the repro case is trivial...
Build the application with expected casing of the project file then all lower-case...
Note the difference in output - the resource path uses the casing specified in the build line.
Somewhat unexpectedly,
dotnet run
manages to use the correct casing...MyApp.zip
Further technical details
The text was updated successfully, but these errors were encountered: