core icon indicating copy to clipboard operation
core copied to clipboard

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

Open ChristianRRL opened this issue 10 years ago • 28 comments

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/

ChristianRRL avatar Dec 02 '16 05:12 ChristianRRL

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

darrellbooker avatar Dec 21 '16 15:12 darrellbooker

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)

geminiyellow avatar Dec 26 '16 07:12 geminiyellow

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

armartinez avatar Dec 30 '16 00:12 armartinez

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

armartinez avatar Dec 31 '16 00:12 armartinez

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

Petermarcu avatar Jan 04 '17 22:01 Petermarcu

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

rmcfarlane82 avatar Jan 05 '17 08:01 rmcfarlane82

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.

armartinez avatar Jan 05 '17 08:01 armartinez

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

geminiyellow avatar Jan 05 '17 15:01 geminiyellow

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 avatar Jan 10 '17 21:01 mhutch

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

geminiyellow avatar Jan 11 '17 03:01 geminiyellow

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 avatar Jan 12 '17 18:01 evermeire

@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.

mhutch avatar Jan 12 '17 18:01 mhutch

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.

evermeire avatar Jan 12 '17 19:01 evermeire

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.

armartinez avatar Jan 23 '17 07:01 armartinez

cc @mrward

mhutch avatar Jan 23 '17 19:01 mhutch

You need a recent Mono 4.8 which should fix that build error:

https://dl.xamarin.com/MonoFrameworkMDK/Macx86/MonoFramework-MDK-4.8.0.459.macos10.xamarin.universal.pkg

mrward avatar Jan 23 '17 19:01 mrward

Thanks, that fixed the issue!

armartinez avatar Jan 24 '17 04:01 armartinez

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

geminiyellow avatar Jan 24 '17 05:01 geminiyellow

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 avatar Feb 05 '17 23:02 erikmartinessanches

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

mrward avatar Feb 06 '17 09:02 mrward