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

6.1.6をUnityのImport Packageからインストールするとエラーで実行できない #878

Open
ANIZA15 opened this issue Dec 17, 2024 · 2 comments

Comments

@ANIZA15
Copy link

ANIZA15 commented Dec 17, 2024

Unity 6000.0.23.f
Windows 11

YetAnotherHttpHandler 1.8.1

まずはエラーとなるコードです。

using MagicOnion;
using MagicOnion.Client;

[MagicOnionClientGeneration(typeof(Test.Shared.IUserService))]
partial class MagicOnionGeneratedClientInitializer { }

エラー文

Assets\Test\Programs\Commons\MagicOnionGeneratedClientInitializer.cs(4,2): error CS0246: The type or namespace name 'MagicOnionClientGenerationAttribute' could not be found (are you missing a using directive or an assembly reference?)

これはUnity6000.0.23f1だから起きるエラーなのでしょうか?

@mayuki
Copy link
Member

mayuki commented Dec 19, 2024

6000.0.23f1 で確認してみましたが単純なプロジェクトですとコンパイルエラーになることはありませんでした。

ただし、 Asssembly Definitinon (.asmdef) で切っている場合には、その Assembly Definition の Assembly Definition Reference に MagicOnion.Client がない場合に同様のエラーが発生したのでそれが原因でしょうか?

@ANIZA15
Copy link
Author

ANIZA15 commented Dec 19, 2024

お忙しい中ご確認してくださりありがとうございます。
MagicOnion.Clientを追加してもUnityのエラーは消えませんでした。

Test.Shared.Unity.asmdefにMagicOnion.Clientを追加した状態が以下のようになります。

{
	"name": "Test.Shared",
	 "references": [
        "MessagePack",
        "MagicOnion.Client",
        "MagicOnion.Abstractions"
    ],
    "optionalUnityReferences": [],
    "includePlatforms": [],
    "excludePlatforms": [],
    "allowUnsafeCode": false,
    "overrideReferences": false,
    "precompiledReferences": [],
    "autoReferenced": true,
    "defineConstraints": []
}

いちおうTest.Sharedのフォルダ直下にありますpackage.jsonとDirectory.Buildも貼っておきます。

{
    "name": "com.test.shared",
    "version": "1.0.0",
    "displayName": "Test Shared Library",
    "description": "Shared library for Testproject, used by both Unity and ASP.NET.",
    "unity": "6000.0"
 }
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <!-- Unity ignores . prefix folder -->
    <ArtifactsPath>$(MSBuildThisFileDirectory).artifacts</ArtifactsPath>
  </PropertyGroup>
</Project>

Test.Sharedの中身も貼っておきます。

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

  <PropertyGroup>
    <TargetFramework>netstandard2.1</TargetFramework>
    <Nullable>enable</Nullable>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="MagicOnion.Abstractions" Version="6.1.6" />
    <PackageReference Include="MessagePack" Version="3.1.0" />
    <PackageReference Include="MessagePack.Annotations" Version="3.1.0" />
    <PackageReference Include="MessagePackAnalyzer" Version="3.1.0">
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
      <PrivateAssets>all</PrivateAssets>
    </PackageReference>
    <PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
  </ItemGroup>

  <ItemGroup>
    <None Remove="**\package.json" />
    <None Remove="**\*.asmdef" />
    <None Remove="**\*.meta" />
  </ItemGroup>

  <Target Name="RestoreLocalTools" BeforeTargets="GenerateMessagePack">
    <Exec Command="dotnet tool restore" />
  </Target>

  <Target Name="GenerateMessagePack" AfterTargets="Build">
    <PropertyGroup>
      <_MessagePackGeneratorArguments>-i ./Test.Shared.csproj -o ../test-client/test/Assets/Scripts/Generated/MessagePack.Generated.cs</_MessagePackGeneratorArguments>
    </PropertyGroup>
    <Exec Command="mpc $(_MessagePackGeneratorArguments)" />
  </Target>  
</Project>

何か足らない情報などありましたらご教授願いたいです。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants