dotnet / project-system

The .NET Project System for Visual Studio
MIT License
967 stars 386 forks source link

Xamarin Android project support #2498

Open jnm2 opened 7 years ago

jnm2 commented 7 years ago

I'd like to reap the benefits of file globbing and convert a Xamarin Android project ( <Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" />).

Even with no other changes, as soon as I add <TargetFramework>monoandroid71</TargetFramework>, Visual Studio no longer allows me to start an emulator.

I can do the full csproj conversion, including <TargetFramework>monoandroid71</TargetFramework>, and it builds fine.

If I do the full csproj conversion but I leave out the <TargetFramework> element it does not restore and reference NuGet packages via <ProjectReference>, and it also adds a few The referenced component 'System.Drawing' could not be found. compiler warnings and this compiler warning:

"C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.CSharp.targets" cannot be imported again. It was already imported at "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.CSharp.targets (38,5)". This is most likely a build authoring error. This subsequent import will be ignored."

I can fix the warnings but I need the package restore to work.

So, due to a few hours' testing, it appears that I can't have globbing without <Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">. I can't have <Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0"> without moving from NuGet-only project.json to <PackageReference>. I can't move to <PackageReference> without <TargetFramework>monoandroid71</TargetFramework>. I can't add <TargetFramework> without losing the ability to run the project.

I know that support for this may be aways out on your roadmap, but what can I do now to achieve globbing without messing up the ability to press F5 to debug in an emulator?

(@onovotny you're usually pushing the envelope here. Have you tried this?)

clairernovotny commented 7 years ago

I don't know about the "head" applications, because there are debugger hooks involved in the project system, but you can get Android class libraries to build with the SDK style projects by using my MSBuild.Sdk.Extras package. I've already added all of the right targets/properties there to light that up. Instructions are on: https://github.com/onovotny/MSBuildSdkExtras

clairernovotny commented 7 years ago

That said, with the "legacy" CSProj, you can use PackageReference with that. Just remove the existing packages.config and any of the Reference HintPath / and NuGet Imports cruft in the csproj and add the <PackageReference nodes. That's likely the best option.

jnm2 commented 7 years ago

I'm already using project.json instead of packages.config for transitivity, so moving to <PackageReference> on its own doesn't buy me a whole lot. My only goal is for globbing to work when I add and move and delete files.

clairernovotny commented 7 years ago

AFAIK, this is currently out of scope for VS 2017 but would be the goal for the next release: https://github.com/dotnet/project-system/blob/master/docs/repo/roadmap.md

The issue exists with legacy ASP.NET projects too -- the way to start debugging is part of the project system and that's not currently supported either. So while I was able to get build/publish to work, that's less-than-helpful without a debug experience.

jnm2 commented 7 years ago

AFAIK, this is currently out of scope for VS 2017 but would be the goal for the next release:

Well, they have a customer for VS vNext then. This and the winforms and WPF stuff can't happen soon enough for me.

csdinon commented 5 years ago

If this won't be fixed can we at least update the documentation to include this issue?

danielmeza commented 4 years ago

@csdinon we need also to define the scope of this, there are other work in the IDE to do, like run the project, pack the app etc. I'm not sure but this is one of the expected features for .net 5 since it pretends to be used as run-time for the Xamarin projects (iOS too), and cause this other project teams need to be involved.

tyeth commented 3 years ago

Prod... Is this anywhere? Just stumbled upon it after attempting to use dotnet instead of msbuild. Am I dead in the water 🦈?