Packing iOS binding projects with NativeReference fails (original) (raw)

I have an iOS binding project that uses @(NativeReference) to pull in the frameworks. If I run a Pack, I get this error:

NuGet.Build.Tasks.Pack.targets(198,5): error : The file '/Users/matthew/Projects/square-bindings/binding/Square.Aardvark/bin/Debug/xamarinios1.0/Native.Square.Aardvark.manifest' to be packed was not found on disk.

My first attempt was to just create that file ('cause I be crazy). That results in another failure:

Unknown native reference type:

So I had a look, it appears to be a "conflict" of .NET (desktop) properties with Xamarin iOS properties. Both use the NativeReference item group, but for different things:

https://github.com/microsoft/msbuild/blob/v16.2.32702/src/Tasks/Microsoft.Common.CurrentVersion.targets#L5548-L5554

<_BuiltProjectOutputGroupOutputIntermediate Include="$(OutDir)$(_DeploymentTargetApplicationManifestFileName)" Condition="'@(NativeReference)'!='' or '@(_IsolatedComReference)'!=''">

My fix so far is to just add this in my project file:

<_BuiltProjectOutputGroupOutputIntermediate Remove="$(OutDir)$(_DeploymentTargetApplicationManifestFileName)" />

I am not sure if there is any other way to avoid this because there aren't actual hooks that I can see. And, I think we should be safe because the Native.xxx.manifest file is not an iOS thing.

I have a sample here:
https://github.com/mattleibow/XamarinNativeReferencesBug

This issue also needs to be addressed in MSBuild directly: dotnet/msbuild#4584