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

Build error when duplicated (vsmac bug) extensions are referenced #5759

Closed
jonathanantoine opened this issue Mar 12, 2019 · 13 comments
Closed
Labels
bug If an issue is a bug or a pull request a bug fix external-visual-studio-for-mac Issues affecting Visual Studio for Mac and are not specific to Xamarin.iOS or Xamarin.Mac

Comments

@jonathanantoine
Copy link

jonathanantoine commented Mar 12, 2019

Steps to Reproduce

  1. Create a main ios project,
  2. Reference a first extension project,
  3. Reference a second extension project,
  4. build in simulator or any other mode.

Expected Behavior

Build success

Actual Behavior

Build fail with this error message :

/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/iOS/Xamarin.iOS.Common.targets(1629,4): error MSB4094: "/Users/me/WKS/CrossTVST/TVST.Android.UI/TVST.iOS.NextToSeeExtension/bin/iPhoneSimulator/Debug/device-builds/iphone10.4-12.1/extensions.appex;/Users/me/WKS/CrossTVST/TVST.Android.UI/TVST.iOS.NextToSeeExtension/bin/iPhoneSimulator/Debug/device-builds/iphone10.4-12.1/extensions.appex" is an invalid value for the "Source" parameter of the "Ditto" task. Multiple items cannot be passed into a parameter of type "Microsoft.Build.Framework.ITaskItem".

Environment

=== Visual Studio Enterprise 2017 for Mac ===

Version 7.8.2 (build 1)
Installation UUID: 37cc8c40-d076-4974-8bf8-344f707f4364
	GTK+ 2.24.23 (Raleigh theme)
	Xamarin.Mac 5.0.0.0 ( / b40230c0)

	Package version: 516000221

=== Mono Framework MDK ===

Runtime:
	Mono 5.16.0.221 (2018-06/b63e5378e38) (64-bit)
	Package version: 516000221

=== NuGet ===

Version: 4.8.0.5385

=== .NET Core ===

Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
	2.2.0
	2.1.2
	2.1.1
	2.0.5
SDK: /usr/local/share/dotnet/sdk/2.2.101/Sdks
SDK Versions:
	2.2.101
	2.1.302
	2.1.301
	2.1.4
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/5.16.0/lib/mono/msbuild/15.0/bin/Sdks

=== Xamarin.Profiler ===

Version: 1.6.4
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Updater ===

Version: 11

=== Apple Developer Tools ===

Xcode 10.1 (14460.46)
Build 10B61

=== Xamarin.Mac ===

Xamarin.Mac not installed. Can't find /Library/Frameworks/Xamarin.Mac.framework/Versions/Current/Version.

=== Xamarin.iOS ===

Version: 12.2.1.15 (Visual Studio Enterprise)
Hash: d60abd198
Branch: d15-9
Build date: 2019-02-01 12:23:29-0500

=== Xamarin.Android ===

Version: 9.1.8.0 (Visual Studio Enterprise)
Android SDK: /Users/jonathanantoine/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		4.4 (API level 19)
		8.1 (API level 27)

SDK Tools Version: 26.1.1
SDK Platform Tools Version: 28.0.1
SDK Build Tools Version: 28.0.3

=== Microsoft Mobile OpenJDK ===

Java SDK: /Users/jonathanantoine/Library/Developer/Xamarin/jdk/microsoft_dist_openjdk_8.0.25
1.8.0-25
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Android Device Manager ===

Version: 7.8.1.0
Hash: 8924ea4a

=== Xamarin Inspector ===

Version: 1.4.3
Hash: db27525
Branch: 1.4-release
Build date: Mon, 09 Jul 2018 21:20:18 GMT
Client compatibility: 1

=== Build Information ===

Release ID: 708020001
Git revision: 13e0e5b7e85ffe742957e6f204bab5c06c644f0e
Build date: 2019-02-27 19:33:14+00
Build branch: release-7.8
Xamarin extensions: 23eaa7c9cdc9a3f55be7bb87b485a790ec82ef25

=== Operating System ===

Mac OS X 10.14.2
Darwin 18.2.0 Darwin Kernel Version 18.2.0
    Mon Nov 12 20:24:46 PST 2018
    root:xnu-4903.231.4~2/RELEASE_X86_64 x86_64

=== Enabled user installed extensions ===

LiveXAML 1.3.31
NuGet Package Management Extensions 0.15


Build Logs

https://gist.github.com/jonathanantoine/95b212c99bf73db3411faae46a607d8e

Example Project (If Possible)

VS bug #818720

@jonathanantoine jonathanantoine changed the title Error when multiple extensions referenced Error when multiple extensions referenced VS For MAC Mar 12, 2019
@jonathanantoine
Copy link
Author

Quick ugly workaround :

  1. Edit your "Xamarin.iOS.Common.targets" file,
  2. Replace the "ditto" part with the below one :
<PropertyGroup>
    <AllResolvedAppExtensionReference>@(_ResolvedAppExtensionReferences)</AllResolvedAppExtensionReference>
    <FirstResolvedAppExtensionReference>$(AllResolvedAppExtensionReference.Split(`;`)[0])</FirstResolvedAppExtensionReference>
</PropertyGroup>
<Ditto
    SessionId="$(BuildSessionId)"
    Condition="'$(IsMacEnabled)' == 'true' And '@(_ResolvedAppExtensionReferences)' != '' And '%(_ResolvedAppExtensionReferences.Identity)' != ''"
    ToolExe="$(DittoExe)"
    ToolPath="$(DittoPath)"
    Source="$(FirstResolvedAppExtensionReference)"
    Destination="$(_AppBundlePath)PlugIns\%(_ResolvedAppExtensionReferences.FileName)%(_ResolvedAppExtensionReferences.Extension)" />

The original snippet was :

<Ditto
    SessionId="$(BuildSessionId)"
    Condition="'$(IsMacEnabled)' == 'true' And '@(_ResolvedAppExtensionReferences)' != '' And '%(_ResolvedAppExtensionReferences.Identity)' != ''"
    ToolExe="$(DittoExe)"
    ToolPath="$(DittoPath)"
    Source="@(_ResolvedAppExtensionReferences)"
    Destination="$(_AppBundlePath)PlugIns\%(_ResolvedAppExtensionReferences.FileName)%(_ResolvedAppExtensionReferences.Extension)" />

@spouliot
Copy link
Contributor

It works when I follow your instructions.
Logs: https://gist.github.com/spouliot/b38f53580abd36672ef5f05bb76dd435

OTOH It seems to skip Ditto so it might have something to do with the type of extensions being used. Can you attach your own solution to the issue ? thanks!

@spouliot spouliot added bug If an issue is a bug or a pull request a bug fix iOS Issues affecting Xamarin.iOS need-info Waiting for more information before the bug can be investigated labels Mar 12, 2019
@spouliot
Copy link
Contributor

Logs were cut down...

Target "_CopyAppExtensionsToBundle" in file "/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/iOS/Xamarin.iOS.Common.targets":
  Building target "_CopyAppExtensionsToBundle" completely.
  Output file "bin/iPhoneSimulator/Debug/device-builds/iphone11.8-12.2/app.app/PlugIns/action.appex" does not exist.
  Task "MakeDir"
    Creating directory "bin/iPhoneSimulator/Debug/device-builds/iphone11.8-12.2/app.app/PlugIns".
  Done executing task "MakeDir".
  Using "Ditto" task from assembly "/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/iOS/Xamarin.iOS.Tasks.dll".
  Task "Ditto"
    /usr/bin/ditto -rsrc /Users/poupou/Projects/gh5759/action/bin/iPhoneSimulator/Debug/device-builds/iphone11.8-12.2/action.appex bin/iPhoneSimulator/Debug/device-builds/iphone11.8-12.2/app.app/PlugIns/action.appex 
  Done executing task "Ditto".
  Task "RemoveDir"
    Directory "bin/iPhoneSimulator/Debug/device-builds/iphone11.8-12.2/app.app/PlugIns/action.appex/_CodeSignature" doesn't exist. Skipping.
    Directory "bin/iPhoneSimulator/Debug/device-builds/iphone11.8-12.2/app.app/../action.appex.dSYM" doesn't exist. Skipping.
  Done executing task "RemoveDir".
Done building target "_CopyAppExtensionsToBundle" in project "app.csproj".
Target "_CopyAppExtensionsToBundle" in file "/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/iOS/Xamarin.iOS.Common.targets":
  Building target "_CopyAppExtensionsToBundle" completely.
  Output file "bin/iPhoneSimulator/Debug/device-builds/iphone11.8-12.2/app.app/PlugIns/blocker.appex" does not exist.
  Task "MakeDir"
  Done executing task "MakeDir".
  Task "Ditto"
    /usr/bin/ditto -rsrc /Users/poupou/Projects/gh5759/blocker/bin/iPhoneSimulator/Debug/device-builds/iphone11.8-12.2/blocker.appex bin/iPhoneSimulator/Debug/device-builds/iphone11.8-12.2/app.app/PlugIns/blocker.appex 
  Done executing task "Ditto".
  Task "RemoveDir"
    Directory "bin/iPhoneSimulator/Debug/device-builds/iphone11.8-12.2/app.app/PlugIns/blocker.appex/_CodeSignature" doesn't exist. Skipping.
    Directory "bin/iPhoneSimulator/Debug/device-builds/iphone11.8-12.2/app.app/../blocker.appex.dSYM" doesn't exist. Skipping.
  Done executing task "RemoveDir".
Done building target "_CopyAppExtensionsToBundle" in project "app.csproj".

so it seems Ditto was called twice - and not with multiple targets.

@spouliot
Copy link
Contributor

It also works with current stable and I only see one extension in your logs: MyApp.iOS.NextToSeeExtension.appex
so I'm not sure it's related to multiple extensions.

@jonathanantoine
Copy link
Author

Here is a repro project @spouliot , you will have to restore nuget packages : CrossTVST.zip

@jonathanantoine
Copy link
Author

OMG, don't ask me why but you are right, the references where not the right ones :

Capture d’écran 2019-03-12 à 15 57 53

A manual edit seems to fix it @spouliot

@spouliot spouliot added external-visual-studio-for-mac Issues affecting Visual Studio for Mac and are not specific to Xamarin.iOS or Xamarin.Mac and removed iOS Issues affecting Xamarin.iOS need-info Waiting for more information before the bug can be investigated labels Mar 12, 2019
@spouliot
Copy link
Contributor

@jstedfast @sgmunn I don't know how it happens (but the SDK don't read, nor modify, .csproj) but it causes issues in builds

@spouliot spouliot changed the title Error when multiple extensions referenced VS For MAC Build error when duplicated (vsmac bug) extensions are referenced Mar 12, 2019
@jstedfast
Copy link
Member

Do we know how this happened? Are there steps that I can perform in the IDE that cause this?

@VincentDondain
Copy link
Contributor

I just created a new iOS single view project + new watchOS project with VSMac master and got the issue.

It's indeed the double watchOS reference:

<ProjectReference Include="..\MyWApp.WatchOSExtension\MyWApp.WatchOSExtension.csproj">
      <Name>MyWApp.WatchOSExtension</Name>
      <Project>{501ACAFB-4C16-47DF-BB63-73FF448B53BE}</Project>
      <IsAppExtension>True</IsAppExtension>
    </ProjectReference>
    <ProjectReference Include="..\MyWApp.WatchOSExtension\MyWApp.WatchOSExtension.csproj">
      <IsAppExtension>true</IsAppExtension>
      <Project>{501ACAFB-4C16-47DF-BB63-73FF448B53BE}</Project>
      <Name>MyWApp.WatchOSExtension</Name>
    </ProjectReference>

Likely something wrong with the template or the new project dialog mechanisms.

Version info: https://gist.github.com/VincentDondain/2b9ce6c3ff443f4262259e7306dc3219

@jstedfast
Copy link
Member

I bet the IPhoneProject logic is duplicated in the TemplateWizard logic

@bo3po
Copy link

bo3po commented Oct 2, 2019

Hi. I just had the same issue. I had a extension project included in iOS then I had to remove it. Then a few days I had to add the same code again. It was removed from the code base as well. When I re-added the new project I got this error. I looked at my git history and the thing is that the IDE did not remove the reference from my csproj file at the time I removed the extension project. My git history says this. So when I re-added the extension project it just added another entry to the iOS csproj file.

This post saved me. Thanks!

... as a note to people that still have problems with the "Ditto" after they have removed the dublicate entry and the code compiles but get this error deploying to a real iOS device: Restart IDE. That did the trick. I'm on VS for Mac.

@restorepro
Copy link

I had the same problem and I spent several hours trying to figure out what it was! I had 2 identical "Project References" in my Xamarin ios .csproj file. Open that file up using the VS for Mac editor (right click the .csproj file and it should be the top-most option) and open it and search for Project Reference. If there are identical entries, comment out one of them and save the changes.

@xamarin xamarin locked as resolved and limited conversation to collaborators May 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug If an issue is a bug or a pull request a bug fix external-visual-studio-for-mac Issues affecting Visual Studio for Mac and are not specific to Xamarin.iOS or Xamarin.Mac
Projects
None yet
Development

No branches or pull requests

6 participants