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

[Community Toolkit] Android Bug: "ReferencePath" does not define a value for metadata "CopyLocal" - Any thoughts or solutions? #2198

Closed
jonmdev opened this issue Mar 25, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@jonmdev
Copy link

jonmdev commented Mar 25, 2024

Version

Release: Stride Community Toolkit NuGet 1.0.0-preview.20
Platform(s): Android

Context

I am attempting to create an integration pathway with Maui to allow crossplatform gaming for iOS/Android/Windows with Microsoft Maui as discussed here.

I am using the Community Toolkit as it can be added to an existing .NET 8 project with a simple NuGet. A code only approach should allow easy integration.

Bug

However, unfortunately, if I create a default Maui project in Visual Studio 2022 and add the Stride Community Toolkit NuGet, even with no other steps taken (not even using Stride, just add package), I can no longer build the project to Android.

Switching the build target to Android leads to Visual Studio reporting the following bug and refusing to build:

Severity Code Description Project File Line Suppression State Details
Error MSB4096 The item "obj\Debug\net8.0-android_Microsoft.Android.Resource.Designer.dll" in item list "ReferencePath" does not define a value for metadata "CopyLocal". In order to use this metadata, either qualify it by specifying %(ReferencePath.CopyLocal), or ensure that all items in this list define a value for this metadata. MauiStride C:\Users\xxx.nuget\packages\stride.core\4.2.0.2067\buildTransitive\Stride.Core.targets 138

Given this is in obj I presume this has something to do with the Community Toolkit itself and something must be fixed inside there. Any thoughts?

Screenshot

Screenshots
android copylocal

Repro Code

Repro Project
https://github.com/jonmdev/MauiStride

To Reproduce

  1. In Visual Studio 2022 go File > New > .NET8 MAUI project
  2. Add Stride Community Toolkit NuGet
  3. Select Android as the build target as in screenshot
  4. See error

Goal

Expected behavior
Need to be able to build to Android with Community Toolkit installed without error in order to continue integration attempts.

I am eager to try to make this a reality. Thanks for any help.

@jonmdev jonmdev added the bug Something isn't working label Mar 25, 2024
@Doprez
Copy link
Contributor

Doprez commented Mar 25, 2024

My experience with Stride has been purely Desktop but I did get a working version running in Android with just Stride a while ago.
Creating a Android template project provides the following csproj file, maybe it will provide some usefull info?

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net8.0-android</TargetFramework>
    <SupportedOSPlatformVersion>21</SupportedOSPlatformVersion>
    <OutputType>Exe</OutputType>
    <RootNamespace>MyGame3</RootNamespace>

    <OutputPath>..\Bin\Android\$(Configuration)\</OutputPath>
    <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>

    <ApplicationId>MyGame3</ApplicationId>
    <ApplicationVersion>1</ApplicationVersion>
    <ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
	  
    <!-- Force msbuild to check to rebuild this assembly instead of letting VS IDE guess -->
    <DisableFastUpToDateCheck>true</DisableFastUpToDateCheck>

    <!-- Use AssemblyName rather than RootNamespace for Resource class otherwise it might clash between some assemblies (i.e. MyGame and MyGame.Android) -->
    <AndroidResgenNamespace>$(AssemblyName)</AndroidResgenNamespace>
  </PropertyGroup>

  <ItemGroup>
    <ProjectReference Include="..\MyGame3\MyGame3.csproj" />
  </ItemGroup>

</Project>

@VaclavElias would you have any thoughts on why just adding the toolkit would introduce this dependancy? I can try to create an android example when I have time after work, I'm assuming its just some config issues since I dont think this should cause any new issues Stride didnt already have.

@VaclavElias
Copy link
Contributor

I have no idea but toolkit is not using a regular Stride project configuration file, that means, Stride will skip certain if conditions in the Stride code base, which might initiliaze certain things? I had some problem with Bepu Physics (or Bullet), where I had to set something through the code related to Physics to access and set certain things because code only is not using configuarion file (at the moment).

If it is this case, it might be easy to find out, but one would need to debug Stride code with the example above and then it might be easty to initilize whatever is missing manually or we would need to put our heads together and find out what needs to be done in Stride code base itself :)

Toolkit, code only part is still trying to figure out, what needs to be initiliazed so all works the same like from a regular Stride project 🤣. And it started from nothing and adding whatever is needed, whatever we find on the way..

@Basewq
Copy link
Contributor

Basewq commented Mar 30, 2024

The "CopyLocal" bug is a engine/build bug.

This targets file (Stride.Core.PostSettings.Dependencies.targets) was changed from "CopyLocal" to "ReferencePath.CopyLocal"

<Target Name="_StrideListDepsFiles" DependsOnTargets="ResolveAssemblyReferences">
<ItemGroup>
<_StrideDepsFile Include="@(ReferencePath->'%(RootDir)%(Directory)%(Filename).ssdeps')" Condition="'%(ReferencePath.CopyLocal)' != 'false' And Exists('%(RootDir)%(Directory)%(Filename).ssdeps')"/>
<_StrideDepsFile Include="@(ReferenceDependencyPaths->'%(RootDir)%(Directory)%(Filename).ssdeps')" Condition="'%(ReferenceDependencyPaths.CopyLocal)' != 'false' And Exists('%(RootDir)%(Directory)%(Filename).ssdeps')"/>
<None Include="@(_StrideDepsFile)" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
</Target>

However, my understanding is this targets file (Stride.Core.targets) did not sync those changes

<Target Name="_StrideListDepsFiles" DependsOnTargets="$(_StrideListDepsFilesDependsOn)">
<ItemGroup>
<_StrideDepsFile Include="@(ReferencePath->'%(RootDir)%(Directory)%(Filename).ssdeps')" Condition="'%(CopyLocal)' != 'false' And Exists('%(RootDir)%(Directory)%(Filename).ssdeps')"/>
<_StrideDepsFile Include="@(ReferenceDependencyPaths->'%(RootDir)%(Directory)%(Filename).ssdeps')" Condition="'%(CopyLocal)' != 'false' And Exists('%(RootDir)%(Directory)%(Filename).ssdeps')"/>
<_StrideDepsFile Include="@(RuntimeCopyLocalItems->'%(RootDir)%(Directory)%(Filename).ssdeps')" Condition="Exists('%(RootDir)%(Directory)%(Filename).ssdeps')"/>
<_StrideDepsFile Include="@(ReferenceCopyLocalPaths->'%(RootDir)%(Directory)%(Filename).ssdeps')" Condition="Exists('%(RootDir)%(Directory)%(Filename).ssdeps')"/>
<!-- Android -->
<_StrideDepsFile Include="@(_ReferencesFromNuGetPackages->'%(RootDir)%(Directory)%(Filename).ssdeps')" Condition="Exists('%(RootDir)%(Directory)%(Filename).ssdeps')"/>
<None Include="@(_StrideDepsFile)" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
</Target>

As per the note directly above, it says "Important: Please keep in sync with Stride.Core.PostSettings.Dependencies.Targets"
however I don't know the full extent of what needs to be sync'd (eg. just change CopyLocal to ReferencePath.CopyLocal & ReferenceDependencyPaths.CopyLocal or maybe copy-paste all six lines?)


For an immediate workaround:

Double clicking on those errors will open the targets file from the nuget package, then change the first %(CopyLocal) to %(ReferencePath.CopyLocal) and the second to %(ReferenceDependencyPaths.CopyLocal)
ie. the changes should look like from

<_StrideDepsFile Include="@(ReferencePath->'%(RootDir)%(Directory)%(Filename).ssdeps')" Condition="'%(CopyLocal)' != 'false' And Exists('%(RootDir)%(Directory)%(Filename).ssdeps')"/>
<_StrideDepsFile Include="@(ReferenceDependencyPaths->'%(RootDir)%(Directory)%(Filename).ssdeps')" Condition="'%(CopyLocal)' != 'false' And Exists('%(RootDir)%(Directory)%(Filename).ssdeps')"/>

to

<_StrideDepsFile Include="@(ReferencePath->'%(RootDir)%(Directory)%(Filename).ssdeps')" Condition="'%(ReferencePath.CopyLocal)' != 'false' And Exists('%(RootDir)%(Directory)%(Filename).ssdeps')"/>
<_StrideDepsFile Include="@(ReferenceDependencyPaths->'%(RootDir)%(Directory)%(Filename).ssdeps')" Condition="'%(ReferenceDependencyPaths.CopyLocal)' != 'false' And Exists('%(RootDir)%(Directory)%(Filename).ssdeps')"/>

@MeharDT
Copy link
Contributor

MeharDT commented Apr 6, 2024

Nice work @Basewq! Are you working on a PR for this? If not I can create one.

As per the note directly above, it says "Important: Please keep in sync with Stride.Core.PostSettings.Dependencies.Targets"
however I don't know the full extent of what needs to be sync'd (eg. just change CopyLocal to ReferencePath.CopyLocal & ReferenceDependencyPaths.CopyLocal or maybe copy-paste all six lines?)

Tagging @xen2 because this change was made in PR #1616, how in sync do we need to keep the two files?

@Basewq
Copy link
Contributor

Basewq commented Apr 7, 2024

Nice work @Basewq! Are you working on a PR for this? If not I can create one.

I'm not, feel free to make one.

@Kryptos-FR
Copy link
Member

Fixed in #2220

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants