-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Packing iOS binding projects with NativeReference fails #4584
Comments
@chamons your team should probably be aware of / involved in this discussion as well :) |
@mattleibow why do you believe this is an issue with MSBuild? |
Because MSBuild (Microsoft.Common.CurrentVersion.targets) assumes that all instances of <ItemGroup>
<_BuiltProjectOutputGroupOutputIntermediate Include="$(OutDir)$(_DeploymentTargetApplicationManifestFileName)" Condition="'@(NativeReference)'!='' or '@(_IsolatedComReference)'!=''">
<TargetPath>$(_DeploymentTargetApplicationManifestFileName)</TargetPath>
<!-- For compatibility with 2.0 -->
<OriginalItemSpec>$(OutDir)$(_DeploymentTargetApplicationManifestFileName)</OriginalItemSpec>
</_BuiltProjectOutputGroupOutputIntermediate>
</ItemGroup> The assumption of the existence of a Maybe it should, then in that case, it appears that MSBuild does not output that file for iOS projects. If that file is created, then it causes issues with other parts of the build. That could be a Xamarin thing - not generating the file - so we could move it to the https://github.com/xamarin/xamarin-macios repo. |
No, we (Xamarin) is not generating that file because it serves us no purpose.
This is the problem: the existence of a |
So we found a workaround for this: unfortunately the workaround does not work when a project uses Example binlog: dotnet.binlog.zip For comparison here's a buildlog using This basically means that we (Xamarin) can't work around it in this scenario, because none of our code is involved in the build (pack) process. |
You should be able to hook into the msbuild/src/Tasks/Microsoft.Common.CrossTargeting.targets Lines 20 to 23 in 12bf0a8
|
You mean we could add a targets file to the |
That's what I expected but I might be missing something in the workload implementation. Do you have a timeframe for when you need the fix? |
The sooner the better of course, but for now it's only been reported internally, so I'm unsure how many customers would be affected. Unless somebody else runs into it, I wouldn't backport this anywhere, and just let it flow to a stable release. I'm guessing that would be with .NET 7 in the fall? Also we have a workaround available, so nobody should be blocked by it. |
We can easily get it into 6.0.400, but it would be very difficult to get it into 6.0.300 at this point. |
6.0.400 should work just fine! |
… (#7564) Fixes #4584. Context The existing code assumes that the presence of NativeReference items means that there will be native manifests (such as WindowsApplication1.exe.manifest). This is an invalid assumption, because NativeReference items are used for other project types, in particular a certain type of Xamarin.iOS projects, and in those cases there won't be any manifest files. The end result is that the build (pack) fails because it tries to include a manifest file that doesn't exist. Changes Made Only include manifest files as built output if the manifest files exist. Testing I modified my local installation and the build (pack) worked just fine.
A workaround if you don't want to use 6.0.400 while it's in preview: <Target Name="RemoveInvalidManifest" AfterTargets="BuiltProjectOutputGroup">
<ItemGroup Condition="!Exists('$(OutDir)$(_DeploymentTargetApplicationManifestFileName)')">
<BuiltProjectOutputGroupOutput Remove="$([System.IO.Path]::GetFullPath('$(OutDir)$(_DeploymentTargetApplicationManifestFileName)'))" />
</ItemGroup>
</Target> This applies the same effect as was done in #7564, and works for me. |
Steps to reproduce
I have created a repository with this issue:
https://github.com/mattleibow/XamarinNativeReferencesBug
I have opened an issue on the MSBuild.Sdk.Extras repository as they can add a workaround there as well: novotnyllc/MSBuildSdkExtras#176
Project file
Command line
Expected behavior
The project builds with two packages as output.
Actual behavior
The project fails with an error:
Environment data
msbuild /version
output:OS info:
macOS Mojave 10.14.5 (18F132)
The text was updated successfully, but these errors were encountered: