Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't run GenerateResource Task #346

Closed
Eilon opened this issue Nov 1, 2016 · 14 comments
Closed

Can't run GenerateResource Task #346

Eilon opened this issue Nov 1, 2016 · 14 comments
Assignees

Comments

@Eilon
Copy link
Member

Eilon commented Nov 1, 2016

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

@Eilon
Copy link
Member Author

Eilon commented Nov 1, 2016

From @livarcocc on November 1, 2016 5:30

cc @nguerrera

@Eilon
Copy link
Member Author

Eilon commented Nov 1, 2016

From @piotrpMSFT on November 1, 2016 5:38

This likely belongs in the SDK repo. @nguerrera do you want me to move it?

@Eilon
Copy link
Member Author

Eilon commented Nov 1, 2016

@livarcocc @piotrpMSFT BTW as @NTaylorMullen said, we think this is a dup, but we just can't find it.

This is the "resources don't seem to work properly" issue I mentioned at today's 4:30pm standup/sync.

@Eilon
Copy link
Member Author

Eilon commented Nov 1, 2016

From @nguerrera on November 1, 2016 16:24

Go ahead and create a new issue on the SDK. Please provide complete repro steps.

@Eilon
Copy link
Member Author

Eilon commented Nov 1, 2016

@NTaylorMullen can you add repro steps to this? E.g. upload a project to GitHub?

@NTaylorMullen
Copy link
Contributor

So I tried to get the most minimal project possible. Looks like it's related to resx files and desktop. Swapped from TargetFrameworks => TargetFramework and I get an additional explosion after the GenerateResource error referenced above:

MSBUILD : error MSB1025: An internal failure occurred while running MSBuild.
System.Reflection.TargetException: Object does not match target type.
   at System.Reflection.RuntimeMethodInfo.CheckConsistency(Object target)
   at System.Reflection.RuntimeMethodInfo.InvokeArgumentsCheck(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.RuntimePropertyInfo.GetValue(Object obj, Object[] index)
   at Microsoft.Build.BackEnd.TaskHostTask.GetPropertyValue(TaskPropertyInfo property)
   at Microsoft.Build.Execution.TaskFactoryWrapper.GetPropertyValue(ITask task, TaskPropertyInfo property)
   at Microsoft.Build.BackEnd.TaskExecutionHost.GetItemOutputs(TaskPropertyInfo parameter, ElementLocation parameterLocation)
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.GatherTaskOutputs(String parameterName, ElementLocation parameterLocation, Boolean outputTargetIsItem, String outputTargetName)
   at Microsoft.Build.BackEnd.TaskBuilder.GatherTaskOutputs(ITaskExecutionHost taskExecutionHost, TaskExecutionMode howToExecuteTask, ItemBucket bucket)
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__25.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at Microsoft.Build.BackEnd.TaskBuilder.<InitializeAndExecuteTask>d__23.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteBucket>d__19.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteTask>d__18.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteTask>d__13.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at Microsoft.Build.BackEnd.TargetEntry.<ProcessBucket>d__48.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at Microsoft.Build.BackEnd.TargetEntry.<ExecuteTarget>d__42.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at Microsoft.Build.BackEnd.TargetBuilder.<ProcessTargetStack>d__22.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at Microsoft.Build.BackEnd.TargetBuilder.<BuildTargets>d__11.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at Microsoft.Build.BackEnd.RequestBuilder.<BuildProject>d__57.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at Microsoft.Build.BackEnd.RequestBuilder.<BuildAndReport>d__49.MoveNext()

MSBUILD : error MSB1025: An internal failure occurred while running MSBuild.
System.Reflection.TargetException: Object does not match target type.
   at Microsoft.Build.CommandLine.MSBuildApp.BuildProject(String projectFile, String[] targets, String toolsVersion, Dictionary`2 globalProperties, ILogger[] loggers, LoggerVerbosity verbosity, DistributedLoggerRecord[] distributedLoggerRecords, Int32 cpuCount, Boolean enableNodeReuse, TextWriter preprocessWriter, Boolean debugger, Boolean detailedSummary)
   at Microsoft.Build.CommandLine.MSBuildApp.Execute(String[] commandLine)

Unhandled Exception: System.Reflection.TargetException: Object does not match target type.
   at Microsoft.Build.CommandLine.MSBuildApp.BuildProject(String projectFile, String[] targets, String toolsVersion, Dictionary`2 globalProperties, ILogger[] loggers, LoggerVerbosity verbosity, DistributedLoggerRecord[] distributedLoggerRecords, Int32 cpuCount, Boolean enableNodeReuse, TextWriter preprocessWriter, Boolean debugger, Boolean detailedSummary)
   at Microsoft.Build.CommandLine.MSBuildApp.Execute(String[] commandLine)
   at Microsoft.Build.CommandLine.MSBuildApp.Main(String[] args)

Anyways, here's the repro. Run test.ps1 (does restore3/builid3) to see explosions. 💥

Repro.zip

@rainersigwald
Copy link
Member

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.

@nguerrera
Copy link
Contributor

Yes, I had just hit this

@nguerrera
Copy link
Contributor

Putting in a workaround in SDK and will file bug on msbuild to fix for RC2.

@masaeedu
Copy link

masaeedu commented Feb 1, 2017

@rainersigwald Where do you recommend putting this? I'm trying to build git://libvirt.org/libvirt-csharp.git, and adding the node you suggested to the first, unconditional PropertyGroup doesn't seem to fix the issue.

@nguerrera
Copy link
Contributor

@masaeedu What version of VS or CLI are you using. This issue should be fixed.

@masaeedu
Copy link

masaeedu commented Feb 1, 2017

@nguerrera Thanks for the quick response. I'm using the CLI, version 1.0.0-rc3-004530. I don't see this issue building from Visual Studio 2017 (version 15.0.0-RC.3+26127.3). If you have the same version of the CLI, could you try cloning the repo I linked, cd-ing to projects/VisualStudio and running dotnet build?

@davidroberts63
Copy link

I see this is closed, but just FYI.

WPF app that was originally built with VS 2015 .NET 4.5.2, opened it up and built with VS 2017:

When building with "Microsoft (R) Build Engine version 15.1.1012.6693" it fails with the OP error.
When building with "Microsoft (R) Build Engine version 14.0.25420.1" it works as expected.
When building with "Microsoft (R) Build Engine version 15.1.1012.6693" with @rainersigwald workaround it works as expected.

This is not using .NET Core, though please excuse me if I misunderstand that part, still getting a hold on .NET Standard, Core, CLI, etc. If there is a better place to put this information let me know and I'd be happy to copy this comment there.

@arabsorkhi
Copy link

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.

GangWang01 pushed a commit to GangWang01/sdk that referenced this issue Mar 20, 2023
Co-authored-by: Vlada Shubina <vshubina@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants