Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MSBuild.Sdk.Extras does not seem to work in VS2017 for Mac #9

Closed
tofutim opened this issue Jun 9, 2017 · 13 comments
Closed

MSBuild.Sdk.Extras does not seem to work in VS2017 for Mac #9

tofutim opened this issue Jun 9, 2017 · 13 comments

Comments

@tofutim
Copy link

tofutim commented Jun 9, 2017

I just opened my solution in VS2017 for Mac. Project targeting Xamarin.Mac20 refuses to load. Any tips?

image

Error is Load failed: Project does not support framework 'Xamarin.Mac, Version=v2.0'

@clairernovotny
Copy link
Collaborator

/cc @mhutch. Not sure about VSfM but if the appropriate set of targets are installed, it should work.... it's just including the things it'd normally do.

@tofutim
Copy link
Author

tofutim commented Jun 9, 2017

@mrward might also have some good ideas. In https://bugzilla.xamarin.com/show_bug.cgi?id=57307, he responded with

Currently the SDK style projects only support .NETCoreApp, .NETStandard and .NETFramework as the target frameworks.

I suspect the Xamarin frameworks would need custom Sdks to allow their MSBuild imports to be included without having to add them yourself in the project file.

I wonder though if MSBuildSdkExtras with some tweaks could get this to work. Or maybe there is some check in VSfM that could be modified so that the import can work.

@mrward
Copy link

mrward commented Jun 9, 2017

I suspect the load failed error is because currently VS for Mac is not allowing other target frameworks for sdk style projects. I should be able to fix that part.

@clairernovotny
Copy link
Collaborator

clairernovotny commented Jun 9, 2017

@mrward it would be good to get some validation that project using this MSBuild.Sdk.Extras package work correctly in VSfM. I don't see why they wouldn't since they load their language targets from the same place that the legacy projects do (same variables, etc). The package just "teaches" the SDK about how to interpret each of the TFM's and what the correct targets are for each.

@tofutim
Copy link
Author

tofutim commented Jun 9, 2017

Let me know if I can help in any way. It would be a lifesaver for me since I just switched our libraries to SDK-style.

@clairernovotny
Copy link
Collaborator

@tofutim you could always use a PC, I hear Windows 10 has a great CLI now with bash ;)

/ducks and runs

@tofutim
Copy link
Author

tofutim commented Jun 9, 2017

Lol. I do use a PC with Windows 10. The problem is that one of the final outputs referencing the libraries is a Cocoa App and it would be nice to be able to debug the app within VSfM. (I switched to SDK-style to avoid messing around with nuspecs...)

image

@tofutim
Copy link
Author

tofutim commented Jun 12, 2017

@mrward Curious to see if you were able to fix the load failed error on your end. If ETA is not too far away we might leave the sln as is.

@tofutim
Copy link
Author

tofutim commented Jun 29, 2017

@onovotny Just got word on some progress from @mrward

Would it be possible to get a fallback VSfM directory integrated into MSBuild.Sdk.Extras?

https://bugzilla.xamarin.com/show_bug.cgi?id=57307

--- Comment #12 from Matt Ward matt.ward@xamarin.com ---
So the only thing I can do on the VSMac side is allow any target framework.
However that by itself does not really help. The project will load but it will
be using an odd target framework. With .NET Core SDK 2.0 installed the target
framework is unknown and the TargetFrameworkMoniker is resolved to
_,Version=1.0.

If you install MSBuild.Sdk.Extras the target framework is now recognised.
However the build fails.

<Project Sdk="Microsoft.NET.Sdk">
 
   <PropertyGroup>
     <TargetFramework>Xamarin.iOS10</TargetFramework>
   </PropertyGroup>
 
         <ItemGroup>
                 <PackageReference Include="MSBuild.Sdk.Extras" Version="1.0.0"
 PrivateAssets="all" />
         </ItemGroup>
 
         <Import Project="$(MSBuildSDKExtrasTargets)"
 Condition="Exists('$(MSBuildSDKExtrasTargets)')" />
 </Project>

(DisplayMissingLanguageTargetsError target) ->

/.nuget/packages/msbuild.sdk.extras/1.0.0/build/netstandard1.0/MSbuildSdkExtras.Common.targets(116,5):
error : The specified language targets for Xamarin.iOS10 is missing. Ensure
correct tooling is installed./r/nMissing File:
/Library/Frameworks/Mono.framework/Versions/5.4.0/lib/mono/xbuild/Xamarin/iOS/Xamarin.iOS.CSharp.targets
[~/Projects/Tests/MyProject/MyProject.csproj]

The Xamarin.iOS.Csharp.targets is available from a different folder:

/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/iOS/Xamarin.iOS.CSharp.targets

A normal Xamarin.iOS project will have an Import of the form:

 <Import
 Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />

The MSBuildExtensionsPath has multiple values:

/Library/Frameworks/Mono.framework/Versions/5.4.0/lib/mono/xbuild:/Library/Frameworks/Mono.framework/External/xbuild/

So more work elsewhere on the Xamarin side or a change in the
MSBuild.Sdk.Extras NuGet package is required.

So I believe I can create a separate addin to allow VSMac 7.0 and above to load
a .NET Core project that targets Xamarin.iOS, without changing VSMac itself,
but nothing else will work. However whether a similar change gets added to
VSMac directly is another question since the project right now will be
unsupported and not work.

@clairernovotny
Copy link
Collaborator

This is now fixed with the latest beta on NuGet. Details on what you need here: https://oren.codes/2017/08/29/use-all-tfms-with-sdk-style-projects-in-visual-studio-for-mac/

@alexfmpe
Copy link

alexfmpe commented Sep 4, 2017

Following the directions in the blog allowed me to convert a xamarin android 'library' .csproj to sdk-style and have it working in Mac OS X - both VSfM and CLI (this unblocked adoption on multi-platform projects).

However, I've been unsuccessful at doing the same for the xamarin android 'app' .csproj.
Is it even possible for sdk-style .csproj to take the 'app' role in xamarin android/iOS? (at least I can't convince VSfM or VS).

I'd like to know if this is just not possible in msbuild-land and/or it's a considered scenario for MSBuildSdkExtras.

@clairernovotny
Copy link
Collaborator

It's not currently possible to have the app projects as SDK style since they need specific support for deployment and debugging.

They can use PackageReference though.

@chucker
Copy link

chucker commented May 26, 2021

It's not currently possible to have the app projects as SDK style since they need specific support for deployment and debugging.

Is that still current? (If so, is that something that needs fixing on the IDE side?)

I got surprisingly far with a Xamarin.Mac20 + VS4Mac project — an app bundle does get generated, and I can manually launch that. However, debugging does not work; apparently, Mono doesn't know where to find the references (even though it does copy them to the app bundle).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants