microsoft / appcenter-sdk-dotnet

Development repository for the App Center SDK for .NET platforms, including Xamarin
Other
307 stars 141 forks source link

Can't use Microsoft.AppCenter.Crashes in Multi-Targeted projects #573

Closed WilliamABradley closed 4 years ago

WilliamABradley commented 6 years ago

The NuGet package installs correctly, but when trying to compile, you get hit with this error:

Microsoft.AppCenter.Crashes.targets(14,5): error : Please build your project specifically for one of the following platforms: x86, x64, ARM

Is there a way around this, or is there a way to compile .NET standard projects for specific architectures?

Edit: On closer assessment, it happens because one of the targets of the project is uap10.0, and that is causing the issue.

MatkovIvan commented 6 years ago

Hi,

Please make sure that you follow this note from our documentation:

If you use the App Center SDK in a portable project (such as Xamarin.Forms), you need to install the packages in each of the projects: the portable, Android and iOS ones (and UWP if you have one).

Let me know if adding packages in the UWP project doesn't solve your problem.

Best, Ivan

WilliamABradley commented 6 years ago

That isn't the problem.

The issue is that I am using MSBuild.SDK.Extras, here is a Project extract:

  <PropertyGroup>
    <TargetFrameworks>netstandard1.4;uap10.0;monoandroid80</TargetFrameworks>
    <AssemblyName>WABradley-Lib</AssemblyName>
    ...

Since this compiles without a specific architecture, it causes an issue. It doesn't compile.

MatkovIvan commented 6 years ago

Ah, got it. I misunderstood the case before. Thanks for the fast clarification.

The problem is that Crashes service for UWP supports only x86, x64, ARM platforms, but not "AnyCPU", because there is a dependency from native code. So, without specification of architecture, it will not compile.

Also, please note that UWP only supports starting Crashes with AppCenter.Start. None of the other API calls provided by the Crashes class are supported on UWP, they work only for Xamarin.

Could you please clarify your case? Why do you need to compile your library with shared code for uap10? Just .NET Standard should be enough for it. You don't need to enumerate platforms here to use code from this library in that platforms.

WilliamABradley commented 6 years ago

My use case is a Shared Library for my apps, that contain platform specific code, which is why it has multiple target frameworks. It should work like a .NET Standard Library for the most part (except that it contains some UWP code), however, the fact that is has uap10.0, means that the error is thrown.

guperrot commented 6 years ago

The error is not thrown by .NET code but by our C++ code that we need to register to the Windows system wide crash reporter, that is why this module with uwp target cannot be included in a project that is compiled with AnyCpu. This C++ code is unfortunately architecture dependent and we don't have any way around this limitation as of now.

guperrot commented 6 years ago

As a side note, the intended use of our SDK in portable app is usually that the portable project is only .NET standard (or PCL for old projects), we also support platform less Visual Studio shared project. And then you have specific projects for Android, iOS and UWP (like when using the template from Xamarin Forms with the portable lib option or shared project option).

Layouts that include an actual single multi-platform project (as in multiple TargetFrameworks at once) is not supported yet.

Perry89 commented 4 years ago

Any update on this issue guys. Looking forward to fix. Just to maybe allow you narrow it down a bit more, Android Version is running fine. It's iOS that is having issues.

guperrot commented 4 years ago

The uwp crash SDK does not require to be built against specific architecture anymore. What is the issue with iOS exactly @Perry89 ?