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

Could not find file AssetPackManifestTemplate.plist in "WriteAssetPackManifest" task when run in DevOps #19669

Closed
rlasker-b2w opened this issue Dec 18, 2023 · 7 comments · Fixed by #19681
Labels
bug If an issue is a bug or a pull request a bug fix
Milestone

Comments

@rlasker-b2w
Copy link

In a .Net Maui project that was migrated from Xamarin, I can run the exact same dotnet publish command on my local Mac and the command completes successfully but when I run the same publish command in Azure DevOps using the DotNetCLI@2 task then I get an error that it cannot find the AssetPackManifestTemplate.plist file during the execution of the WriteAssetPackManifest task.

Steps to Reproduce

  1. create an .Net Maui app
  2. create a Azure DevOps build using the DotNetCoreCLI@2
  3. command: "publish"
  4. arguments: -c "$(BuildConfiguration)" -f "net7.0-ios" -o $(build.artifactstagingdirectory) -r ios-arm64 --self-contained
  5. vmImage: macos-13
  6. DotNetVersion: 7.0.403
  7. xcode version 15.0.1

Expected Behavior

UseDotNet@2 task completes successfully

Actual Behavior

error MSB4018: The "WriteAssetPackManifest" task failed unexpectedly.
error MSB4018: System.IO.FileNotFoundException: Could not find file '/Users/runner/work/1/s/Inform.Forms/obj/Test/net7.0-ios/ios-arm64/ipa/Payload/Inform.Forms.app/AssetPackManifestTemplate.plist'.

Environment

Pool: Azure Pipelines
Image: macos-13
Agent: Hosted Agent

Starting: Build iOS App

Task : .NET Core
Description : Build, test, package, or publish a dotnet application, or run a custom dotnet command
Version : 2.221.0
Author : Microsoft Corporation
Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/build/dotnet-core-cli

/Users/runner/hostedtoolcache/dotnet/dotnet publish /Users/runner/work/1/s/Inform.Forms/Inform.Forms.csproj -c Test -f net7.0-ios -o /Users/runner/work/1/a -r ios-arm64 --self-contained
MSBuild version 17.7.3+4fca21998 for .NET

/Users/runner/hostedtoolcache/dotnet/packs/Microsoft.iOS.Sdk/16.4.7129/tools/msbuild/iOS/Xamarin.iOS.Common.targets(534,3): error MSB4018: The "WriteAssetPackManifest" task failed unexpectedly. [/Users/runner/work/1/s/Inform.Forms/Inform.Forms.csproj::TargetFramework=net7.0-ios]
/Users/runner/hostedtoolcache/dotnet/packs/Microsoft.iOS.Sdk/16.4.7129/tools/msbuild/iOS/Xamarin.iOS.Common.targets(534,3): error MSB4018: System.IO.FileNotFoundException: Could not find file '/Users/runner/work/1/s/Inform.Forms/obj/Test/net7.0-ios/ios-arm64/ipa/Payload/Inform.Forms.app/AssetPackManifestTemplate.plist'. [/Users/runner/work/1/s/Inform.Forms/Inform.Forms.csproj::TargetFramework=net7.0-ios]
/Users/runner/hostedtoolcache/dotnet/packs/Microsoft.iOS.Sdk/16.4.7129/tools/msbuild/iOS/Xamarin.iOS.Common.targets(534,3): error MSB4018: File name: '/Users/runner/work/1/s/Inform.Forms/obj/Test/net7.0-ios/ios-arm64/ipa/Payload/Inform.Forms.app/AssetPackManifestTemplate.plist' [/Users/runner/work/1/s/Inform.Forms/Inform.Forms.csproj::TargetFramework=net7.0-ios]
/Users/runner/hostedtoolcache/dotnet/packs/Microsoft.iOS.Sdk/16.4.7129/tools/msbuild/iOS/Xamarin.iOS.Common.targets(534,3): error MSB4018: at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirError) [/Users/runner/work/1/s/Inform.Forms/Inform.Forms.csproj::TargetFramework=net7.0-ios]
/Users/runner/hostedtoolcache/dotnet/packs/Microsoft.iOS.Sdk/16.4.7129/tools/msbuild/iOS/Xamarin.iOS.Common.targets(534,3): error MSB4018: at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, UnixFileMode openPermissions, Int64& fileLength, UnixFileMode& filePermissions, Func4 createOpenException) [/Users/runner/work/1/s/Inform.Forms/Inform.Forms.csproj::TargetFramework=net7.0-ios] /Users/runner/hostedtoolcache/dotnet/packs/Microsoft.iOS.Sdk/16.4.7129/tools/msbuild/iOS/Xamarin.iOS.Common.targets(534,3): error MSB4018: at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable1 unixCreateMode) [/Users/runner/work/1/s/Inform.Forms/Inform.Forms.csproj::TargetFramework=net7.0-ios]
/Users/runner/hostedtoolcache/dotnet/packs/Microsoft.iOS.Sdk/16.4.7129/tools/msbuild/iOS/Xamarin.iOS.Common.targets(534,3): error MSB4018: at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access) [/Users/runner/work/1/s/Inform.Forms/Inform.Forms.csproj::TargetFramework=net7.0-ios]
/Users/runner/hostedtoolcache/dotnet/packs/Microsoft.iOS.Sdk/16.4.7129/tools/msbuild/iOS/Xamarin.iOS.Common.targets(534,3): error MSB4018: at Xamarin.MacDev.PObject.FromFile(String fileName, Boolean& isBinary) in /Users/builder/azdo/_work/1/s/xamarin-macios/external/Xamarin.MacDev/Xamarin.MacDev/PListObject.cs:line 336 [/Users/runner/work/1/s/Inform.Forms/Inform.Forms.csproj::TargetFramework=net7.0-ios]
/Users/runner/hostedtoolcache/dotnet/packs/Microsoft.iOS.Sdk/16.4.7129/tools/msbuild/iOS/Xamarin.iOS.Common.targets(534,3): error MSB4018: at Xamarin.MacDev.PDictionary.FromFile(String fileName, Boolean& isBinary) in /Users/builder/azdo/_work/1/s/xamarin-macios/external/Xamarin.MacDev/Xamarin.MacDev/PListObject.cs:line 751 [/Users/runner/work/1/s/Inform.Forms/Inform.Forms.csproj::TargetFramework=net7.0-ios]
/Users/runner/hostedtoolcache/dotnet/packs/Microsoft.iOS.Sdk/16.4.7129/tools/msbuild/iOS/Xamarin.iOS.Common.targets(534,3): error MSB4018: at Xamarin.MacDev.PDictionary.FromFile(String fileName) in /Users/builder/azdo/_work/1/s/xamarin-macios/external/Xamarin.MacDev/Xamarin.MacDev/PListObject.cs:line 739 [/Users/runner/work/1/s/Inform.Forms/Inform.Forms.csproj::TargetFramework=net7.0-ios]
/Users/runner/hostedtoolcache/dotnet/packs/Microsoft.iOS.Sdk/16.4.7129/tools/msbuild/iOS/Xamarin.iOS.Common.targets(534,3): error MSB4018: at Xamarin.iOS.Tasks.WriteAssetPackManifestTaskBase.Execute() in /Users/builder/azdo/_work/1/s/xamarin-macios/msbuild/Xamarin.iOS.Tasks/Tasks/WriteAssetPackManifestTaskBase.cs:line 28 [/Users/runner/work/1/s/Inform.Forms/Inform.Forms.csproj::TargetFramework=net7.0-ios]
/Users/runner/hostedtoolcache/dotnet/packs/Microsoft.iOS.Sdk/16.4.7129/tools/msbuild/iOS/Xamarin.iOS.Common.targets(534,3): error MSB4018: at Xamarin.iOS.Tasks.WriteAssetPackManifest.Execute() in /Users/builder/azdo/_work/1/s/xamarin-macios/msbuild/Xamarin.iOS.Tasks/Tasks/WriteAssetPackManifest.cs:line 11 [/Users/runner/work/1/s/Inform.Forms/Inform.Forms.csproj::TargetFramework=net7.0-ios]
/Users/runner/hostedtoolcache/dotnet/packs/Microsoft.iOS.Sdk/16.4.7129/tools/msbuild/iOS/Xamarin.iOS.Common.targets(534,3): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [/Users/runner/work/1/s/Inform.Forms/Inform.Forms.csproj::TargetFramework=net7.0-ios]
/Users/runner/hostedtoolcache/dotnet/packs/Microsoft.iOS.Sdk/16.4.7129/tools/msbuild/iOS/Xamarin.iOS.Common.targets(534,3): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask) [/Users/runner/work/1/s/Inform.Forms/Inform.Forms.csproj::TargetFramework=net7.0-ios]

@rolfbjarne
Copy link
Member

Can you get a binlog from the failing build in Azure DevOps?

You can get a binlog by adding -bl:msbuild.binlog to the build command, like this:

-c "$(BuildConfiguration)" -f "net7.0-ios" ... -bl:msbuild:binlog

and then attach the resulting msbuild.binlog here.

@rolfbjarne rolfbjarne added the need-info Waiting for more information before the bug can be investigated label Dec 19, 2023
@rolfbjarne rolfbjarne added this to the Future milestone Dec 19, 2023
@rlasker-b2w
Copy link
Author

@rolfbjarne thank you for the response on this issue. I have attached the bin log.
msbuild.binlog.txt

@microsoft-github-policy-service microsoft-github-policy-service bot added need-attention An issue requires our attention/response and removed need-info Waiting for more information before the bug can be investigated labels Dec 19, 2023
@rlasker-b2w
Copy link
Author

I thought perhaps using the output parameter in the publish command ("-o $(build.artifactstagingdirectory)") could have resulted in why the missing file could not be found since the task was looking in the source ("work/1/s") directory and the output parameter was sending it to the artifacts directory ("work/1/a").

Could not find file '/Users/runner/work/1/s/Inform.Forms/obj/Test/net7.0-ios/ios-arm64/ipa/Payload/Inform.Forms.app/AssetPackManifestTemplate.plist'.

I realized, though, that even when I had removed that parameter in order to do the binlog I still got the same error.

/Users/runner/hostedtoolcache/dotnet/dotnet publish /Users/runner/work/1/s/Inform.Forms/Inform.Forms.csproj -c Test -f net7.0-ios -r ios-arm64 --self-contained -bl:msbuild.binlog

@rolfbjarne
Copy link
Member

The difference is that the codesigning profile is an AdHoc profile, and that enters a different codepath during the build, which ends up failing.

@rlasker-b2w
Copy link
Author

If I am following you, it is the "Codesign" task that was skipped due to the following false condition?

Task "Codesign" skipped, due to false condition;
('$(IsMacEnabled)' == 'true' And '@(_AssetPack)' != '' And '$(_DistributionType)' == 'AppStore')
was evaluated as
('true' == 'true' And 'obj/Test/net7.0-ios/ios-arm64/ipa/Payload/Inform.Forms.app/OnDemandResources/com.b2wsoftware.inform.ICON_TOOLBAR__MENU_ALERT.assetpack/' != '' And 'AdHoc' == 'AppStore').

I'm curious why it would work in my local environment then since it would be using the same AdHoc profile? The Xamarin iOS version on my environment is 16.4.0.23.

@rolfbjarne
Copy link
Member

rolfbjarne commented Dec 20, 2023

No, this is executed when it fails (and normally isn't executed):

<WriteAssetPackManifest
SessionId="$(BuildSessionId)"
Condition="'$(IsMacEnabled)' == 'true' And '$(_DistributionType)' == 'AdHoc' And Exists('$(_IntermediateODRDir)')"
TemplatePath="$(_IpaAppBundleDir)AssetPackManifestTemplate.plist"
OutputFile="$(_IpaAppBundleDir)AssetPackManifest.plist"
OnDemandResourceUrl="$(OnDemandResourcesUrl)"
IsStreamable="$(IsStreamable)"
/>

Can you try adding this to your csproj to see if it works around the problem?

<Target Name="InvokeTarget_CreateAssetPackManifest" DependsOnTargets="_CreateAssetPackManifest" AfterTargets="_CopyResourcesToBundle" />

if it doesn't, please attach an updated binlog.

@rolfbjarne rolfbjarne added bug If an issue is a bug or a pull request a bug fix and removed need-attention An issue requires our attention/response labels Dec 20, 2023
@rolfbjarne
Copy link
Member

Note to self: I can reproduce using the iTravel submission sample with an AdHoc profile.

rolfbjarne added a commit to rolfbjarne/xamarin-macios that referenced this issue Dec 20, 2023
…ixes xamarin#19669.

We're calling the _CreateAssetPackManifest target during the build for legacy
Xamarin apps, but somehow this seems to have been skipped over when
implementing .NET support.

The reason this has not showed up before is that it requires:

* OnDemand resources.
* An AdHoc provisioning profile (and a distribution certificate).

The last part makes it rather complicated to write a unit test, so this has
been verified manually.

Fixes xamarin#19669.
rolfbjarne added a commit that referenced this issue Jan 2, 2024
…ixes #19669. (#19681)

We're calling the _CreateAssetPackManifest target during the build for legacy
Xamarin apps, but somehow this seems to have been skipped over when
implementing .NET support.

The reason this has not showed up before is that it requires:

* OnDemand resources.
* An AdHoc provisioning profile (and a distribution certificate).

The last part makes it rather complicated to write a unit test, so this has
been verified manually.

Fixes #19669.
vs-mobiletools-engineering-service2 pushed a commit to vs-mobiletools-engineering-service2/xamarin-macios that referenced this issue Jan 2, 2024
…ixes xamarin#19669.

We're calling the _CreateAssetPackManifest target during the build for legacy
Xamarin apps, but somehow this seems to have been skipped over when
implementing .NET support.

The reason this has not showed up before is that it requires:

* OnDemand resources.
* An AdHoc provisioning profile (and a distribution certificate).

The last part makes it rather complicated to write a unit test, so this has
been verified manually.

Fixes xamarin#19669.
rolfbjarne pushed a commit that referenced this issue Jan 3, 2024
…uring the build. Fixes #19669. (#19714)

We're calling the _CreateAssetPackManifest target during the build for legacy
Xamarin apps, but somehow this seems to have been skipped over when
implementing .NET support.

The reason this has not showed up before is that it requires:

* OnDemand resources.
* An AdHoc provisioning profile (and a distribution certificate).

The last part makes it rather complicated to write a unit test, so this has
been verified manually.

Fixes #19669.

Backport of #19681
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug If an issue is a bug or a pull request a bug fix
Projects
None yet
2 participants