dotnet cli does not run sln solution from Visual Studio
See original GitHub issueSteps 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:
- Created 7 years ago
- Comments:6 (2 by maintainers)
Top GitHub Comments
But in VS2017 the project compiles fine for all frameworks. So how to fix this in AppVeyor and Travis builds???
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.