【问题标题】:Problems when building Uno Platform project from command line从命令行构建 Uno Platform 项目时的问题
【发布时间】:2021-03-16 15:08:55
【问题描述】:

我创建了一个基于 netstandard 2.0 的类库,并成功地将其包含在一个 droid 应用程序中。从 Visual Studio 调试时一切正常。我尝试使用dotnet 从命令行构建它,这就是发生奇怪事情的地方。构建运行良好,但在运行 dotnet pack 时,它说构建失败,出现 0 个错误和 0 个警告:

   1:5>UnoResourcesGeneration:
         Generating resources for platform :
       Done executing task "ResourcesGenerationTask_v331aaa6f42492821058b51435a68065fe542d4fe" -- FAILED.
   1:5>Done Building Project "....csproj" (_GetFrameworkAssemblyReferences target(s)) -- FAILED.
     1>Done executing task "MSBuild" -- FAILED.
     1>Done building target "_WalkEachTargetPerFramework" in project "....csproj" -- FAILED.
     1>Done Building Project "....csproj" (pack target(s)) -- FAILED.

Build FAILED.
    0 Warning(s)
    0 Error(s)

这是使用 .NET 5 运行的,我尝试使用 .NET Core 2 对其进行编译,此外还会产生以下消息:

      "....csproj" (pack target) (1) ->
       (_UnoSourceGenerator target) ->
         ...\.nuget\packages\uno.sourcegenerationtasks\3.0.0\build\netstandard1.0\Uno.SourceGenerationTasks.targets(134,2): error MSB4062: The "Uno.SourceGeneratorTasks.SourceGenerationTask_v7422c41155a89db34b1e3241cd4c4761f2cabf5f" task could not be loaded from the assembly ...\.nuget\packages\uno.sourcegenerationtasks\3.0.0\build\netstandard1.0\..\Dev15.0\netcoreapp3.1\Uno.SourceGeneratorTasks.v7422c41155a89db34b1e3241cd4c4761f2cabf5f.dll. Could not load file or assembly 'System.Runtime, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. [....csproj]

(已删除路径)

谁能发现那里发生了什么?在 Visual Studio 中工作正常,但我需要能够从命令行构建它才能在 GitHub Actions 上设置构建。

【问题讨论】:

    标签: uno-platform


    【解决方案1】:

    .NET Core 2 是构建 Uno 平台应用程序的不受支持的目标。您需要至少升级到 .NET Core 3.1。

    【讨论】:

    • .NET Core 2 只是我尝试看看是否可行的东西。它产生了 .NET Core 3.1 和 .NET 5 没有出现的错误消息。但它也不适用于 3.1/5。
    • 在这种情况下,您可能正在做一些我们错过的事情。您能否在 Uno 中使用您正在尝试执行的操作的示例代码打开一个问题,并在那里发布 msbuild.binlog 文件? platform.uno/docs/articles/…
    • 我发现一旦我从针对netstandard2.0 的类库中引用Uno.UI 就会发生构建错误。在我的示例中,我有这样的引用:Example.Droid &gt; CustomLib &gt; Uno.UI。我不确定是否支持从类库中引用 Uno.UI?如果是这样,我会继续创建一个问题。
    • 知道了。是的,但它需要特定的配置。如果要构建跨目标库,请使用 Visual Studio 扩展提供的Cross-Platform Library (Uno Platform) 模板。
    • 改用跨平台库肯定有帮助。不是我在使用dotnet 构建时看到一个真正的构建错误,说它不受支持(也在文档中说明)。我可以从 Visual Studio 中打包,所以我只需要弄清楚如何从命令行复制它。非常感谢您对此提供的帮助。如果您愿意,请随时回顾答案,我会将其标记为已回答?
    猜你喜欢
    • 2010-09-11
    • 2010-10-17
    • 2010-09-27
    • 2010-09-17
    • 2011-08-13
    • 1970-01-01
    • 2018-01-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多