Core: Visual Studio for Mac Preview - Crossplatform ASP.NET Core 1 not working

Created on 2 Dec 2016  路  28Comments  路  Source: dotnet/core

I'm attempting to get an ASP.NET Core 1 solution to work on both Mac/Windows, but I am having issues with it. I am working with Mac Visual Studio Version Preview 1 (7.0 build 347) and Windows Visual Studio Version 4.6.01586.

When I attempt to open/compile the ASP.NET Core 1 application from Windows to Mac it tells me to "Please build the project and retry, or set the OutputPath and AssemblyName properties appropriately to point at the correct location for the target assembly" but when I try to build it doesn't work (it skips).

Vice versa, when I try it from Mac to Windows it doesn't even open and it comes up with the error message "Error while trying to load the project '.../ASPNETCoreWindows.xproj': Unknown solution item type.

Not sure if the different version types plays any role in this, but I also noticed that the Mac version doesn't include a project.json. For reference, I have two blank ASP.NET that can be used for testing:
https://github.com/ChristianRRL/ASPNETCoreWindows/
https://github.com/ChristianRRL/ASPNETCoreMac/

Most helpful comment

VS for Mac supports the new .NET Core csproj format introduced in VS 2017 RC. It does not support the old xproj format. As mentioned earlier you can migrate xproj to csproj on the commandline using dotnet migrate.

An update to the VS 2017 RC made further simplification to project files using a new MSBuild concept called SDKs, as explained here:
https://blogs.msdn.microsoft.com/dotnet/2016/12/12/updating-visual-studio-2017-rc-net-core-tooling-improvements

You can identify csproj projects that use the SDK feature by the Sdk attribute in the toplevel Project attribute and a lack of <Import> elements. VS for Mac (as of Preview 2) does not yet support MSBuild SDKs, but we're working on adding it.

All 28 comments

I get the same "Unknown solution item type" error trying to open any Core 1 solution in VS for Mac

maybe the same error.

dotnet --info
.NET Command Line Tools (1.0.0-preview2-1-003177)

Runtime Environment:
 OS Name:     Mac OS X

but the project options show

Target framework: .NetCoreApp 1.0(Not installed)

Same error here, solution and projects created with Visual Studio 2015 Community Edition

dotnet --info
.NET Command Line Tools (1.0.0-preview4-004233)

Runtime Environment:
OS Name:     Mac OS X 
OS Version:  10.12
OS Platform: Darwin

I've also tried to open a Visual Studio 2017 RC migrated solution and I get the same error but now the error message mentions the new csproj project files :
{filename}.csproj: Unknown solution item type

@barrytang , Anything you can add here? Do you know who the right people are to pull in to help out?

I'm getting the same issue, I saw somewhere that you might need to do a dotnet migrate command. https://docs.microsoft.com/en-us/dotnet/articles/core/preview3/tools/dotnet-migrate

I did the migration when I opened the project in Visual Studio 2017 RC but still got the same problem. I also noticed that when creating a new ASP.NET Core solution in Visual Studio for Mac Preview, the solution version is marked as Visual Studio 2012.

yep, I did the same thing, so, I think maybe is a problem with the version for mac. Because it's too old.

VS for Mac supports the new .NET Core csproj format introduced in VS 2017 RC. It does not support the old xproj format. As mentioned earlier you can migrate xproj to csproj on the commandline using dotnet migrate.

An update to the VS 2017 RC made further simplification to project files using a new MSBuild concept called SDKs, as explained here:
https://blogs.msdn.microsoft.com/dotnet/2016/12/12/updating-visual-studio-2017-rc-net-core-tooling-improvements

You can identify csproj projects that use the SDK feature by the Sdk attribute in the toplevel Project attribute and a lack of <Import> elements. VS for Mac (as of Preview 2) does not yet support MSBuild SDKs, but we're working on adding it.

@mhutch thanks. csproj also not working now on VS for Mac (Alpha channel), hope it will working next update.

I miss the project.json file because it was easy to perform a build and release on a Mac using terminal or with Azure and Visual Studio Team service builds/release.

dotnet restore
dotnet publish -c Release --version-suffix $(Build.BuildId)

and viola I would have a build done in VSTS and get the build id into my ASP.NET core assembly. Now, with VS 2017 and Visual Studio for Mac ASP.NET Core web application projects no longer have a project.json file and are using MSBuild instead. Hopefully, I can execute msbuild on the Mac and figure out how to deploy to Azure from the Mac terminal. I shouldn't have to rely on my IDE to always perform a build and deploy. Speaking of Visual Studio for Mac, where is the Azure deployment feature that I see a screenshot of at the Xamarin website???

@evermeire yes, Mono ships msbuild on Mac, which can be used from the command-line, and VS for Mac and the dotnet command-line both use MSBuild to build projects.

We don't currently ship Azure deployment support in VS for Mac, what screenshot are you seeing this in? We do have support for integrating mobile apps with Azure connected services but that's something different.

Thanks for the quick reply. On this page, https://www.visualstudio.com/vs/visual-studio-mac/, I was looking at this screenshot.
https://www.visualstudio.com/wp-content/uploads/2016/11/[email protected]

but now that I look closer at it, it is the Azure App Service and not Azure WebApp Service

I quickly realized that msbuild does execute on a Mac via terminal after I posted the above comment, so I am good there.

Latest Preview 3 now opens the new csproj based projects, but I'm getting the following error when building any project.

Error MSB4057: The target "Build" does not exist in the project. (MSB4057)

I have updated the .NET Core SDK 1.0.0-rc4 as instructed in the release notes.

cc @mrward

Thanks, that fixed the issue!

when i upgrade to the latest version of vs for mac, everything working well. woo~

I made a .NETCore app in VS for Mac and tried to open the project in VS Enterprise 2015 for Win, but the one-way project upgrade dialog appears in VS for Win. After accepting the dialog my Program.cs file does not appear in the Project Explorer and when debug-building: "Project not selected to build for this solution configuration" and when release-building: "error MSB4040: There is no target in the project."

@erikmartinessanches - Visual Studio 2015 does not support .NET Core projects. You will need to use Visual Studio 2017.

@mrward @erikmartinessanches Visual Studio 2015 _does_ support .Net Core, if you install the .Net Core tools for it. I've had no issues using VS Enterprise 2015.

https://www.microsoft.com/net/core#windowsvs2015 (step 2)

@iBeizsley - Sorry to be more clear I mean Visual Studio 2015 does not support the new sdk style MSBuild projects. As far as I am aware the .NET Core support in Visual Studio 2015 uses the xproj project file format.

@mrward Ah, yep, this is correct.

@ChristianRRL, @mhutch, it sounds like this issue has been addressed. I'm going to close. Please reopen if that is not the case.

brand new mac, brand new install of VS
Visual Studio for Mac Preview
Version Preview 3 (7.0 build 1077)
Installation UUID: ceb38681-66a2-4bcc-a307-ae740919b339
Runtime:
Mono 4.8.0 (mono-4.8.0-branch/cd26828) (64-bit)
GTK+ 2.24.23 (Raleigh theme)
Package version: 408000459

latest version of mono
Mono JIT compiler version 4.8.0 (mono-4.8.0-branch/cd26828 Fri Jan 13 14:32:29 EST 2017)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
TLS: normal
SIGSEGV: altstack
Notification: kqueue
Architecture: x86
Disabled: none
Misc: softdebug
LLVM: yes(3.6.0svn-mono-master/8b1520c)
GC: sgen

latest version of dotnet
.NET Command Line Tools (1.0.0-rc4-004793)

Product Information:
Version: 1.0.0-rc4-004793
Commit SHA-1 hash: 6091a4704c

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-004793

I still have the
Target framework: .NetCoreApp 1.0(Not installed

This is an error you are getting from VS for Mac?

@smnbss - Visual Studio for Mac does not correctly report the .NetCoreApp target framework as being installed in the project options. The 'Not installed' message can be ignored if you have a recent .NET Core SDK installed, which you have.

Petermarcu commented 2 hours ago
This is an error you are getting from VS for Mac?
Yes
It was compiling and running the app though.

Was this page helpful?
0 / 5 - 0 ratings