question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't run GenerateResource Task

See original GitHub issue

From @NTaylorMullen on November 1, 2016 0:30

After dotnet migrate ing Microsoft.AspNetCore.Razor.Design attempting to restore3/build3 results in the following error:

C:\Users\nimullen\AppData\Local\Microsoft\dotnet\sdk\1.0.0-preview3-003892\Microsoft.Common.CurrentVersion.targets(2801,5): error MSB4216: Could not run the "GenerateResource" task because MSBuild could not create or connect to a task host with runtime "CLR4" and architecture "x86". Please ensure that (1) the requested runtime and/or architecture are available on the machine, and (2) that the required executable "C:\Users\nimullen\AppData\Local\Microsoft\dotnet\sdk\1.0.0-preview3-003892\MSBuild.exe" exists and can be run. [C:\Users\nimullen\Documents\GitHub\RazorTooling\src\Microsoft.AspNetCore.Razor.Design\Microsoft.AspNetCore.Razor.Design.csproj]

I thought I recalled seeing an issue associated with GenerateResource task being unable to run but I can no longer find it. Feel free to move or close this issue as a duplicate.

Dotnet info:

.NET Command Line Tools (1.0.0-preview3-003892)

Product Information:
 Version:            1.0.0-preview3-003892
 Commit SHA-1 hash:  5301f08423

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.14393
 OS Platform: Windows
 RID:         win10-x64

Copied from original issue: dotnet/cli#4556

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:14 (10 by maintainers)

github_iconTop GitHub Comments

12reactions
rainersigwaldcommented, Nov 1, 2016

Workaround: define this property

<GenerateResourceMSBuildArchitecture>CurrentArchitecture</GenerateResourceMSBuildArchitecture>

in your project.

The problem is that CoreResGen has logic to attempt to find the right resgen.exe (it matters because you want to use the right bitness + framework version for what you’re targeting). That logic only works if there are multiple task hosts available, though, which isn’t true in .NET Core MSBuild.

I think setting that property in an SDK .props/.targets is the right fix for this. .NET Core builds should use the CurrentArchitecture because that’s the only one that’s guaranteed to be runnable.

One wrinkle: I’m not entirely sure what differs when a different resgen runs. I think it’s ok to just use the one that works, but I don’t understand it deeply.

0reactions
arabsorkhicommented, Apr 2, 2021

I had the same Error (in version 16.9.3) but By Repairing Visual Studio 2019, Updating last version of windows 10, close VS, delete .vs hidden folder (under solution folder) ,bin and obj folder then restart your VS . Fortunately My problem was solved.

Read more comments on GitHub >

github_iconTop Results From Across the Web

.net - Could not run the "GenerateResource" task because ...
1) add these xml node in your xxx.csproj file: · 2) add a system environment variable called DisableOutOfProcTaskHost and set its value to...
Read more >
error MSB4216: Could not run the "GenerateResource ...
Hi, Help please, i am getting this error, while i am trying to build dotnet core app in teacmcity. error MSB4216: Could not...
Read more >
GenerateResource task failed
This is the error I'm getting. Build usually hangs for a long time like 30 mins, then eventually failed. See the attachment for...
Read more >
Could not run the “GenerateResource” task because MSBuild ...
Could not run the “GenerateResource” task because MSBuild could not create or connect to a task host with runtime “CLR2” and architecture “x86”....
Read more >
Could not run the “GenerateResource” task
Click Start >> right-click Computer >> Properties >> Advanced system settings >> click Environment Variables button to open the dialog, then ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found