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.

different build result between dotnet cli and visual studio 2022

See original GitHub issue

Describe the bug

Hi there, I’m trying use dotnet cli more in my daily workflow instead of using VS2022 for everything.

Doing so, I noticed some difference between dotnet cli and VS2022. For example, if I clone and build this project .

On VS2022, it would work and generate a ‘.exe’ file.

However, if I run dotnet build ./YAPA/YAPA.csproj it would complain:

dotnet build .\YAPA.csproj
Microsoft (R) Build Engine version 17.1.1+a02f73656 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

  Determining projects to restore...
  Nothing to do. None of the projects specified contain packages to restore.
  Restoring NuGet packages...
  To prevent NuGet from downloading packages during build, open the Visual Studio Options dialog, click on the Package Manager node and uncheck 'Allow NuGet to download missing packages'.
  All packages listed in packages.config are already installed.
C:\Program Files\dotnet\sdk\6.0.202\Microsoft.Common.CurrentVersion.targets(3261,5): error MSB4216: Could not run the "GenerateResource" task because MSBuild could not create or connect to a task host with runtime "NET" 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:\Program Files\dotnet\sdk\6.0.202\MSBuild.dll" exists and can be run. [C:\source\repos\YAPA-1.2.0\YAPA\YAPA.csproj]
C:\Program Files\dotnet\sdk\6.0.202\Microsoft.Common.CurrentVersion.targets(3283,7): error MSB4028: The "GenerateResource" task's outputs could not be retrieved from the "FilesWritten" parameter. Object does not match target type. [C:\source\repos\YAPA-1.2.0\YAPA\YAPA.csproj]

Build FAILED.

I wonder if I’m setting something wrong, can you please help out? Or is there any document that explains how to make sure the dotnet cli can be configured in a way that would produce consistent behaviour as VS2022?

To Reproduce

Exceptions (if any)

Further technical details

  • Include the output of dotnet --info
  • The IDE (VS / VS Code/ VS4Mac) you’re running on, and its version

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
cathysullcommented, May 6, 2022

@ianzhang366 - Yes, we recommend using the .NET Upgrade Assistant https://aka.ms/dotnet-upgrade-assistant to assist in converting your projects to the sdk-style. The tool also helps with a lot of the other heavy lifting when upgrading to .NET 6+. Let us know if you have any other questions!

0reactions
mairawcommented, May 5, 2022

If this is a .NET Framework project, I think the recommended tool now is the upgrade assistant, no? For that, the documentation is located at https://docs.microsoft.com/en-us/dotnet/core/porting/upgrade-assistant-overview

/cc @cathysull

Read more comments on GitHub >

github_iconTop Results From Across the Web

dotnet build command - .NET CLI
The dotnet build command builds the project and its dependencies into a set of binaries. The binaries include the project's code in Intermediate ......
Read more >
Change the build output directory - Visual Studio (Windows)
In Visual Studio 2022, there are different Project Designer user interfaces, depending on your project type. C# . NET Framework and all Visual...
Read more >
Build .NET ClickOnce Applications from the Command Line
Learn how to build .NET Visual Studio projects from the command line, which allows you to reproduce a build using an automated process....
Read more >
dotnet publish command - .NET CLI
dotnet publish compiles the application, reads through its dependencies specified in the project file, and publishes the resulting set of files ...
Read more >
Visual Studio 2022. Can I build project with `dotnet ...
1 Answer 1 ... MSBuild can be hosted within another application and this is what the dotnet tool is doing. It is the...
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