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.

dotnet cli does not run sln solution from Visual Studio

See original GitHub issue

Steps to reproduce

We have a solution MyServer.sln which is a socket server that is a Visual Studio console app. It was created in Microsoft Visual Studio 2015 (but I think the sln file is 2012 format). I can run this app just fine in Windows and macOS (using Visual Studio for Mac).

However, we want to build and deploy this server as a dotnet core app so that we can run it inside Ubuntu linux in a Docker container using one of the official Microsoft docker containers.

However, although I can run this app using the play button within Visual Studio for Mac on macOS, I cannot run it on the macOS terminal commandline. How do I do this? Or alternatively, how can I create, from a VisualStudio .sln file, the needed project files to run the app with the dotnet cli?

# After compiling with Visual Studio for Mac

bash> dotnet MyServer.ConsoleHost/bin/Debug/MyServer.ConsoleHost.exe

A fatal error was encountered. The library 'libhostpolicy.dylib' required to execute the application was not found in '/Users/joel/src/MyPlatform/Platform/MyServer.ConsoleHost/bin/Debug'.

# No MyServer.ConsoleHost.dll is generated by Visual Studio for Mac, so I can't see how to run that

So the question is, given a regular old Visual Studio .sln solution that people are using to develop a console app in Windows, how do I use dotnet core to build and run this for Linux or macOS from a headless terminal command line.

I don’t want to create project.json file since MS is moving away from those and I’m not sure how. Is there some way to magically use the .sln file from dotnet cli to build for execution by dotnet cli?

Also, when I try to dotnet msbuild I get tons of errors about

/usr/local/share/dotnet/sdk/1.0.0-rc4-004771/Microsoft.Common.CurrentVersion.targets(1111,5): error MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.6.1" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend.

Note that the MyServer.sln solution only uses basic dotnet core stuff. It doesn’t use any Windows-specific stuff. It is a sln file because it was extracted from a larger sln that builds a Windows game but we extracted some of the common code to build the server.

Expected behavior

I should be able to build and run a regular old Visual Studio sln solution using dotnet cli on macOS and Linux.

Actual behavior

Doesn’t work.

Environment data

dotnet --info output:

.NET Command Line Tools (1.0.0-rc4-004771)

Product Information: Version: 1.0.0-rc4-004771 Commit SHA-1 hash: 4228198f0e

Runtime Environment: OS Name: Mac OS X OS Version: 10.12 OS Platform: Darwin RID: osx.10.12-x64 Base Path: /usr/local/share/dotnet/sdk/1.0.0-rc4-004771

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

6reactions
StefHcommented, Mar 18, 2017

But in VS2017 the project compiles fine for all frameworks. So how to fix this in AppVeyor and Travis builds???

0reactions
sathesh-pandiancommented, Apr 9, 2018

Any updates on targeting .NET framework 2.0? i have seen people migrated .NET framework 2.0 apps in DotNet core and got struck like me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to load and run a .NET 6 project without .SLN file ...
After that load the solution and then right-click the solution in Solution Explorer and select Add Existing Project and select your project. You ......
Read more >
dotnet-run command not working as expected
The easy fix is to just change into the project directory, and then run dotnet run again. cd C:\Users\hp\Desktop\HW-3\FirstTestApp\FirstTestApp ...
Read more >
Creating and editing solution files with the .NET CLI
In this post, I show how to manage sln files with the .NET command line interface (CLI). See how to create sln files,...
Read more >
Cannot debug net6.0-macos Apps - Developer Community
2 I tried to disable “.Net Core Debugger” extension (Main menu (Visual Studio) - Extensions - Installed). After this the VS is able...
Read more >
Do we really need a solution file for dot net coding these ...
I know you can dotnet build on the cli for both projects and for ... Obviously, this did not open in a Visual...
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