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
{{ message }}
Repository navigation
Generating strongly typed resource files not currently supported on .NET Core MSBuild #2272
What is a right repo to ask about ResGen in dotnet build?
Currently I try to generate strongly typed resources and get error: C:\Users\user\AppData\Local\Microsoft\dotnet\sdk\2.0.0-preview2-006502\Microsoft.Common.CurrentVersion.targets(2921,5): error : Generating strongly typed resource files not currently supported on .NET Core MSBuild [C:\Users\user\Documents\GitHub\iSazonov\PowerShell\src\Microsoft.PowerShell.CoreCLR.Eventing\Microsoft.PowerShell.CoreCLR.Eventing.csproj]
Huh, we should have had an issue open for this already but I couldn't find one.
Is the project compiled without FEATURE_CODEDOM?
Yes, it is: CodeDOM wasn't available at the time of the initial port to .NET Core and we haven't lit up this feature after the initial port.
It looks like CodeDOM is available in .NET Core 2.0 (for code-writing scenarios, though not compilation), so we should be able to enable that feature flag everywhere after we move to targeting .NET Core 2.0.
Workarounds
Build with full framework MSBuild.exe (on a Windows machine).
Check in the (generated) .cs files and update them when necessary (from Windows/full framework).
Hello Team, I am sorry if I am asking silly question: So what I understand is that if I am using dotnet sdk on my Mac & vscode for editing, I can't create a strongly typed controller from db ?
(I know there is visual studio version now available for Mac).
Thanks 👍
@livarcocc, when is this feature going to be supported. Absence of this makes it difficult to build code from Linux, i.e. requires manual overhead of generating and checking in strongly typed resource access wrapper.
From a quick look this morning, CodeDOM is not enough to bring this back: the task also depends on System.Resources.ResXResourceReader which is full-framework only.
@rainersigwald I see you've already completed some work in #4420 but you also call out some work such as 'Check to ensure that the reader type is available when not targeting netcoreapp3.0' (which is ticked now).
Does this mean that a project targeting .Net Standard (2.0) can already auto-generate the *.Designer.cs files (in my case just the simple case of only strings)? Using preview8, it does not seem to do that at the moment or is a property needed to opt into this at the moment for netstandard2.0 projects? Thanks.
@bergmeister That wasn't directly related to code generation, and StronglyTypedResourceGenerator doesn't work in preview8. #4588 should enable it in the future, though.
If your code is open source, I can add it to the set of things I'm testing before merging that PR. Just feed me a link :)
@rainersigwald I tried to use Preview9 on my project (links in last comment) but dotnet build does not create me the strongly typed .cs file from .resx file although the csproj has the following:
@bergmeister Yes, this is fairly confusing: your build was configured so that building inside Visual Studio would regenerate the source files, but building on the command line would not (regardless of whether it was msbuild.exe or dotnet build doing it).
When I tested your repo I applied this patch to change to build-time generation in all cases:
@bergmeister Can you please file a new issue with details? How exactly does it fail to work--build error? Runtime failure doing something in particular?
Ok, I can create an issue with a minimized repro.
It fails on build due to the Strings.Designer.cs not being created by the build (I deleted the file locally as I'd expect dotnet build to create it automatically, is my assumption here right?)
@bergmeister, I think I've reproduced the problem; it looks like something's gone wrong with the namespace/class name that we're generating. Don't worry about minimizing but please do file a bug.
Thanks, it works now with your 2 new lines.
The StronglyTypedNamespace line seems to be only necessary because we have the following in the csproj (from the days when we converted from project.json to the new csproj format to make it work using Visual Studio) <RootNamespace>Microsoft.Windows.PowerShell.ScriptAnalyzer</RootNamespace>
Now that the command line works, we don't care about Visual Studio too much tbh but I will check that later today (using VS 16.2.5 somehow the setting to allow VS to use preview SDKs has gone or can I use the VS Preview for that now only?)
Is the StronglyTypedClassName property needed due to the resx file not matching the project name? I tried renaming it to Engine.resx and changed the references in the csproj but the property was still needed then.
Should I file the 'bug' to be specific about this project or rather generic that those properties seem to be needed? As a user I can be flexible, but I'd like to know what is the cleanest/simplest csproj declaration to have this working (optionally also in a way that it works with VS)
Activity
livarcocc commentedon Jul 7, 2017
From @wli3 on July 6, 2017 17:9
Hi iSazonov,
Could you try to add resx files like this? https://github.com/dotnet/sdk/blob/cd25d6bbfc2aac61cc790c511900427ac64fdaa8/TestAssets/TestProjects/KitchenSink/TestApp/TestApp.csproj#L24
(This is a part of SDK automatic test asset)
livarcocc commentedon Jul 7, 2017
From @iSazonov on July 6, 2017 17:29
@wli3 Thanks! Please clarify - I don't see strongly typed config in the csproj.
livarcocc commentedon Jul 7, 2017
From @wli3 on July 6, 2017 17:35
Hi @iSazonov ,
I think I misunderstood you. Looks like your project is in Github, could you share the specific strongly typed config code link?
livarcocc commentedon Jul 7, 2017
From @iSazonov on July 6, 2017 17:41
@wli3 I'll publish the sample tomorrow from my local branch.
livarcocc commentedon Jul 7, 2017
From @iSazonov on July 7, 2017 5:34
I published my test. See last
<ItemGroup> in https://github.com/iSazonov/PowerShell/blob/cproj-psversion-from-git-resx/src/Microsoft.PowerShell.CoreCLR.Eventing/Microsoft.PowerShell.CoreCLR.Eventing.csprojBuild command:
I believe error place is here
Is the project compiled without FEATURE_CODEDOM?
livarcocc commentedon Jul 7, 2017
I am moving this issue over to MSBuild. FYI @rainersigwald
rainersigwald commentedon Jul 7, 2017
Huh, we should have had an issue open for this already but I couldn't find one.
Yes, it is: CodeDOM wasn't available at the time of the initial port to .NET Core and we haven't lit up this feature after the initial port.
It looks like CodeDOM is available in .NET Core 2.0 (for code-writing scenarios, though not compilation), so we should be able to enable that feature flag everywhere after we move to targeting .NET Core 2.0.
Workarounds
Build with full framework MSBuild.exe (on a Windows machine).
Check in the (generated)
.csfiles and update them when necessary (from Windows/full framework).iSazonov commentedon Jul 8, 2017
@rainersigwald Thanks!
PowerShell Core is multiplatform project and we cannot use MSBuild.exe. Currently we use a simple tool developed by @vors.
Yes, it is. So I believe it is easy to fix the Issue.
foo-baar commentedon Sep 12, 2017
Hello Team, I am sorry if I am asking silly question: So what I understand is that if I am using dotnet sdk on my Mac & vscode for editing, I can't create a strongly typed controller from db ?
(I know there is visual studio version now available for Mac).
Thanks 👍
iSazonov commentedon Sep 13, 2017
Team, .Net Core 2.0 RTM was out - could you please milestone the Issue?
hrushib commentedon Apr 13, 2018
@livarcocc, when is this feature going to be supported. Absence of this makes it difficult to build code from Linux, i.e. requires manual overhead of generating and checking in strongly typed resource access wrapper.
rainersigwald commentedon Apr 19, 2018
From a quick look this morning, CodeDOM is not enough to bring this back: the task also depends on
System.Resources.ResXResourceReaderwhich is full-framework only.28 remaining items
bergmeister commentedon Aug 19, 2019
@rainersigwald I see you've already completed some work in #4420 but you also call out some work such as 'Check to ensure that the reader type is available when not targeting netcoreapp3.0' (which is ticked now).
Does this mean that a project targeting .Net Standard (2.0) can already auto-generate the
*.Designer.csfiles (in my case just the simple case of only strings)? Usingpreview8,it does not seem to do that at the moment or is a property needed to opt into this at the moment fornetstandard2.0projects? Thanks.rainersigwald commentedon Aug 19, 2019
@bergmeister That wasn't directly related to code generation, and StronglyTypedResourceGenerator doesn't work in preview8. #4588 should enable it in the future, though.
If your code is open source, I can add it to the set of things I'm testing before merging that PR. Just feed me a link :)
bergmeister commentedon Aug 19, 2019
@rainersigwald Thanks for the quick answer. An example project that you could use for testing is this one: https://github.com/PowerShell/PSScriptAnalyzer/tree/master/Engine
Just remove the
Strings.Designer.csfile, remove theglobal.jsonone directory above and then just typedotnet build(all NuGet packages are on NuGet.org so everything should just build out of the box).bergmeister commentedon Sep 14, 2019
@rainersigwald I tried to use
Preview9on my project (links in last comment) butdotnet builddoes not create me the strongly typed .cs file from .resx file although the csproj has the following:Am I am missing something, is there something that needs to be enabled explicitly for a .net standard (2.0) library?
rainersigwald commentedon Sep 16, 2019
@bergmeister Yes, this is fairly confusing: your build was configured so that building inside Visual Studio would regenerate the source files, but building on the command line would not (regardless of whether it was
msbuild.exeordotnet builddoing it).When I tested your repo I applied this patch to change to build-time generation in all cases:
bergmeister commentedon Sep 17, 2019
@rainersigwald Thanks for the info, however, even with the
rc1of .Net Core 3 and your local changes, it does not work for merainersigwald commentedon Sep 17, 2019
@bergmeister Can you please file a new issue with details? How exactly does it fail to work--build error? Runtime failure doing something in particular?
bergmeister commentedon Sep 17, 2019
Ok, I can create an issue with a minimized repro.
It fails on build due to the
Strings.Designer.csnot being created by the build (I deleted the file locally as I'd expectdotnet buildto create it automatically, is my assumption here right?)rainersigwald commentedon Sep 17, 2019
Yes, that's correct--the copy in the checked-in tree is not needed when switching over to build-time generation.
rainersigwald commentedon Sep 17, 2019
@bergmeister, I think I've reproduced the problem; it looks like something's gone wrong with the namespace/class name that we're generating. Don't worry about minimizing but please do file a bug.
rainersigwald commentedon Sep 17, 2019
@bergmeister with this I can get your project to compile:
We can chase down exactly why all this is necessary in your bug.
bergmeister commentedon Sep 19, 2019
Thanks, it works now with your 2 new lines.
The
StronglyTypedNamespaceline seems to be only necessary because we have the following in the csproj (from the days when we converted from project.json to the new csproj format to make it work using Visual Studio)<RootNamespace>Microsoft.Windows.PowerShell.ScriptAnalyzer</RootNamespace>Now that the command line works, we don't care about Visual Studio too much tbh but I will check that later today (using VS 16.2.5 somehow the setting to allow VS to use preview SDKs has gone or can I use the VS Preview for that now only?)
Is the
StronglyTypedClassNameproperty needed due to the resx file not matching the project name? I tried renaming it toEngine.resxand changed the references in the csproj but the property was still needed then.Should I file the 'bug' to be specific about this project or rather generic that those properties seem to be needed? As a user I can be flexible, but I'd like to know what is the cleanest/simplest csproj declaration to have this working (optionally also in a way that it works with VS)
rainersigwald commentedon Sep 19, 2019
File whatever's easiest for you and we can broaden/narrow it as we investigate.