Eto: Não é possível construir um caso trivial no linux

Criado em 6 abr. 2018  ·  16Comentários  ·  Fonte: picoe/Eto

Comportamento esperado

Eu posso construir com dotnet

Comportamento real

Não consigo construir com dotnet

Etapas para reproduzir o problema

  1. instale dotnet-sdk-2.0.0
  2. instalar mono-devel
  3. instalar monocompleto
  4. dotnet new -i "Eto.Forms.Templates::*"
  5. dotnet new etoapp -g -sln
  6. restauração dotnet
  7. compilação dotnet

Código que demonstra o problema

[alan<strong i="19">@localhost</strong> Testing]$ dotnet new etoapp -g -sln
The template "Eto App" was created successfully.
[alan<strong i="20">@localhost</strong> Testing]$ dotnet restore
  Restoring packages for /home/alan/Documents/Testing/Testing.Desktop/Testing.Desktop.csproj...
  Restoring packages for /home/alan/Documents/Testing/Testing/Testing.csproj...
  Generating MSBuild file /home/alan/Documents/Testing/Testing.Desktop/obj/Testing.Desktop.csproj.nuget.g.props.
  Generating MSBuild file /home/alan/Documents/Testing/Testing.Desktop/obj/Testing.Desktop.csproj.nuget.g.targets.
  Generating MSBuild file /home/alan/Documents/Testing/Testing/obj/Testing.csproj.nuget.g.props.
  Generating MSBuild file /home/alan/Documents/Testing/Testing/obj/Testing.csproj.nuget.g.targets.
  Restore completed in 302.81 ms for /home/alan/Documents/Testing/Testing/Testing.csproj.
  Restore completed in 296.78 ms for /home/alan/Documents/Testing/Testing.Desktop/Testing.Desktop.csproj.
[alan<strong i="21">@localhost</strong> Testing]$ dotnet build
Microsoft (R) Build Engine version 15.3.409.57025 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Testing -> /home/alan/Documents/Testing/Testing/bin/Debug/netstandard1.6/Testing.dll
  Testing.Desktop -> /home/alan/Documents/Testing/Testing.Desktop/bin/Debug/net461/Testing.Desktop.exe
  Creating Testing.Desktop.app in target directory
/home/alan/.nuget/packages/eto.platform.mac64/2.4.0/build/MacTemplate.targets(115,3): error : MSB4801: The task factory "CodeTaskFactory" is not supported on the .NET Core version of MSBuild. [/home/alan/Documents/Testing/Testing.Desktop/Testing.Desktop.csproj]
/home/alan/.nuget/packages/eto.platform.mac64/2.4.0/build/MacTemplate.targets(115,3): error MSB4036: The "_UpdatePList" task was not found. Check the following: 1.) The name of the task in the project file is the same as the name of the task class. 2.) The task class is "public" and implements the Microsoft.Build.Framework.ITask interface. 3.) The task is correctly declared with <UsingTask> in the project file, or in the *.tasks files located in the "/usr/share/dotnet/sdk/2.0.0" directory. [/home/alan/Documents/Testing/Testing.Desktop/Testing.Desktop.csproj]

Build FAILED.

/home/alan/.nuget/packages/eto.platform.mac64/2.4.0/build/MacTemplate.targets(115,3): error : MSB4801: The task factory "CodeTaskFactory" is not supported on the .NET Core version of MSBuild. [/home/alan/Documents/Testing/Testing.Desktop/Testing.Desktop.csproj]
/home/alan/.nuget/packages/eto.platform.mac64/2.4.0/build/MacTemplate.targets(115,3): error MSB4036: The "_UpdatePList" task was not found. Check the following: 1.) The name of the task in the project file is the same as the name of the task class. 2.) The task class is "public" and implements the Microsoft.Build.Framework.ITask interface. 3.) The task is correctly declared with <UsingTask> in the project file, or in the *.tasks files located in the "/usr/share/dotnet/sdk/2.0.0" directory. [/home/alan/Documents/Testing/Testing.Desktop/Testing.Desktop.csproj]
    0 Warning(s)
    2 Error(s)

Em particular, esta linha parece importante.
The task factory "CodeTaskFactory" is not supported on the .NET Core version of MSBuild.

Especificações

  • Versão: 2.4.0
  • Plataforma(s): (Fedora Gtk3)

Comentários muito úteis

@voronoipotato Crie o arquivo .csproj, não o arquivo de solução. A solução parece conter o projeto Mac, e isso sempre falhará ao compilar no Linux.

Observação: isso não é recomendado, pois alguns recursos estão ausentes ou não funcionam no net core, por exemplo, WebView. @cra0zy poderia falar mais sobre isso.

Não.... tudo funciona no .NET Core, incluindo o WebView.

Todos 16 comentários

Obrigado por relatar o problema. No entanto, você precisa usar msbuild vez de dotnet build .

Isso funcionou. Quando tentei a mesma coisa para F #
dotnet new etoapp -g -sln -lang F#
então eu recebo

/home/alan/Documents/Testing/Testing.Desktop/Testing.Desktop.fsproj(124,5): error : This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is ../packages/Eto.Forms.2.4.0/build/Eto.Forms.targets.
Done Building Project "/home/alan/Documents/Testing/Testing.Desktop/Testing.Desktop.fsproj" (default targets) -- FAILED.
Done Building Project "/home/alan/Documents/Testing/Testing.sln" (default targets) -- FAILED.

Build FAILED.

"/home/alan/Documents/Testing/Testing.sln" (default target) (1) ->
"/home/alan/Documents/Testing/Testing.Desktop/Testing.Desktop.fsproj" (default target) (3) ->
(EnsureNuGetPackageBuildImports target) -> 
  /home/alan/Documents/Testing/Testing.Desktop/Testing.Desktop.fsproj(124,5): error : This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is ../packages/Eto.Forms.2.4.0/build/Eto.Forms.targets.

    0 Warning(s)
    1 Error(s)

com msbuild.

Provavelmente devemos adicionar isso ao guia de início rápido que você não pode usar o dotnet build.

@voronoipotato nuget restore .
O comando NuGet deve ser instalado com mono-completo, mas se não, você pode instalá-lo separadamente.

Se você só precisa suportar a plataforma Linux, você pode usar Eto.Platform.Gtk nuget e target netcoreapp2.0 e você poderá construir usando dotnet build

Aqui está um exemplo do meu csproj:

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

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Eto.Platform.Gtk" Version="2.4.1" />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\Eto.Desktop\Eto.Desktop.csproj" />
  </ItemGroup>

</Project>

Nota: Isso não é recomendado, porque alguns recursos estão faltando ou não funcionam no net core, por exemplo WebView .

@voronoipotato Crie o arquivo .csproj, não o arquivo de solução. A solução parece conter o projeto Mac, e isso sempre falhará ao compilar no Linux.

Observação: isso não é recomendado, pois alguns recursos estão ausentes ou não funcionam no net core, por exemplo, WebView. @cra0zy poderia falar mais sobre isso.

Não.... tudo funciona no .NET Core, incluindo o WebView.

A solução parece conter o projeto Mac, e isso sempre falhará ao compilar no Linux.

Na verdade, isso está incorreto. Os projetos mac não usam mais o tipo de projeto MonoMac obsoleto e usam o estilo sdk csproj. Os pacotes nuget do Eto agora incluem arquivos .targets que construirão o pacote .app para você mesmo no Windows ou Linux. No entanto, o projeto Xamarin.Mac opcional ainda será compilado apenas em um Mac.

Provavelmente devemos adicionar isso ao guia de início rápido que você não pode usar o dotnet build

Feito! Eu adicionei nuget restore e msbuild ao exemplo para apontar as pessoas na direção certa.

Ah, eu pensei que ele estava gerando as soluções por plataforma, ainda não experimentei os novos modelos.

@voronoipotato isso está funcionando para você agora usando nuget/msbuild?

Eu também criei #1080 para portar os arquivos .targets para suportar dotnet build no futuro.

Eu também não sou capaz de construir um caso trivial.

Passos para reproduzir

mkdir -p eto-test
cd eto-test
dotnet new -i "Eto.Forms.Templates::*"
dotnet new etoapp -lang F#
nuget restore
msbuild

O que acontece

Microsoft (R) Build Engine version 15.4.0.0 ( Wed Nov 29 14:47:19 UTC 2017) for Mono
Copyright (C) Microsoft Corporation. All rights reserved.

Build started 4/13/2018 9:34:26 AM.
Project "[…]/eto-test/eto-test.sln" on node 1 (default targets).
ValidateSolutionConfiguration:
  Building solution configuration "Debug|Any CPU".
Project "[…]/eto-test/eto-test.sln" (1) is building "[…]/eto-test/eto-test/eto-test.fsproj" (2) on node 1 (default targets).
PrepareForBuild:
  Creating directory "bin/Debug/net45/".
  Creating directory "obj/Debug/net45/".
/usr/share/dotnet/sdk/2.0.3/Sdks/Microsoft.NET.Sdk/build/Microsoft.PackageDependencyResolution.targets(323,5): error : Assets file '[…]/eto-test/eto-test/obj/project.assets.json' not found. Run a NuGet package restore to generate this file. [[…]/eto-test/eto-test/eto-test.fsproj]
  Build continuing because "ContinueOnError" on the task "ReportAssetsLogMessages" is set to "ErrorAndContinue".
/usr/share/dotnet/sdk/2.0.3/Sdks/Microsoft.NET.Sdk/build/Microsoft.PackageDependencyResolution.targets(165,5): error : Assets file '[…]/eto-test/eto-test/obj/project.assets.json' not found. Run a NuGet package restore to generate this file. [[…]/eto-test/eto-test/eto-test.fsproj]
Done Building Project "[…]/eto-test/eto-test/eto-test.fsproj" (default targets) -- FAILED.
Project "[…]/eto-test/eto-test.sln" (1) is building "[…]/eto-test/eto-test.Desktop/eto-test.Desktop.fsproj" (3) on node 1 (default targets).
GenerateFSharpTextResources:
  Creating directory "obj/Debug/".
PrepareForBuild:
  Creating directory "bin/Debug/".
Done Building Project "[…]/eto-test/eto-test.Desktop/eto-test.Desktop.fsproj" (default targets) -- FAILED.
Done Building Project "[…]/eto-test/eto-test.sln" (default targets) -- FAILED.

Build FAILED.

"[…]/eto-test/eto-test.sln" (default target) (1) ->
"[…]/eto-test/eto-test/eto-test.fsproj" (default target) (2) ->
(ReportAssetsLogMessages target) -> 
  /usr/share/dotnet/sdk/2.0.3/Sdks/Microsoft.NET.Sdk/build/Microsoft.PackageDependencyResolution.targets(323,5): error : Assets file '[…]/eto-test/eto-test/obj/project.assets.json' not found. Run a NuGet package restore to generate this file. [[…]/eto-test/eto-test/eto-test.fsproj]


"[…]/eto-test/eto-test.sln" (default target) (1) ->
"[…]/eto-test/eto-test/eto-test.fsproj" (default target) (2) ->
(RunResolvePackageDependencies target) -> 
  /usr/share/dotnet/sdk/2.0.3/Sdks/Microsoft.NET.Sdk/build/Microsoft.PackageDependencyResolution.targets(165,5): error : Assets file '[…]/eto-test/eto-test/obj/project.assets.json' not found. Run a NuGet package restore to generate this file. [[…]/eto-test/eto-test/eto-test.fsproj]

    0 Warning(s)
    2 Error(s)

Time Elapsed 00:00:01.66

Sistema

Fedora 27x86_64.

dnf repository-packages packages-microsoft-com-prod list installed retorna:

aspnetcore-store-2.0.0.x86_64            2.0.0-1             @packages-microsoft-com-prod
aspnetcore-store-2.0.3.x86_64            2.0.3-1             @packages-microsoft-com-prod
dotnet-host.x86_64                       2.0.6-1             @packages-microsoft-com-prod
dotnet-hostfxr-2.0.3.x86_64              2.0.3-1             @packages-microsoft-com-prod
dotnet-runtime-2.0.3.x86_64              2.0.3-1             @packages-microsoft-com-prod
dotnet-sdk-2.0.3.x86_64                  2.0.3-1             @packages-microsoft-com-prod

dnf repository-packages mono-centos7-stable list installed retorna:

fsharp.noarch              4.1.33-0.xamarin.2.epel7                               @mono-centos7-stable
libgdiplus0.x86_64         4.2-0.xamarin.2.epel7                                  @mono-centos7-stable
libmonosgen-2_0-1.x86_64   5.10.1.20-0.xamarin.3.epel7                            @mono-centos7-stable
mono-core.x86_64           5.10.1.20-0.xamarin.3.epel7                            @mono-centos7-stable
mono-data.x86_64           5.10.1.20-0.xamarin.3.epel7                            @mono-centos7-stable
mono-data-oracle.x86_64    5.10.1.20-0.xamarin.3.epel7                            @mono-centos7-stable
mono-data-sqlite.x86_64    5.10.1.20-0.xamarin.3.epel7                            @mono-centos7-stable
mono-devel.x86_64          5.10.1.20-0.xamarin.3.epel7                            @mono-centos7-stable
mono-extras.x86_64         5.10.1.20-0.xamarin.3.epel7                            @mono-centos7-stable
mono-mvc.x86_64            5.10.1.20-0.xamarin.3.epel7                            @mono-centos7-stable
mono-wcf.x86_64            5.10.1.20-0.xamarin.3.epel7                            @mono-centos7-stable
mono-web.x86_64            5.10.1.20-0.xamarin.3.epel7                            @mono-centos7-stable
mono-winforms.x86_64       5.10.1.20-0.xamarin.3.epel7                            @mono-centos7-stable
mono-winfxcore.x86_64      5.10.1.20-0.xamarin.3.epel7                            @mono-centos7-stable
msbuild.noarch             1:15.4+xamarinxplat.2017.11.27.11.23-0.xamarin.1.epel7 @mono-centos7-stable
msbuild-libhostfxr.x86_64  2.0.0.2017.07.06.00.01-0.xamarin.1.epel7               @mono-centos7-stable
msbuild-sdkresolver.noarch 1:15.4+xamarinxplat.2017.11.27.11.23-0.xamarin.1.epel7 @mono-centos7-stable
nuget.noarch               2.12+mono-0.xamarin.3.epel7                            @mono-centos7-stable

O erro já diz o que está errado... "Execute uma restauração de pacote NuGet para gerar este arquivo.", e não, isso não significa executar nuget restore , esse comando não funciona dessa maneira. A solução mais fácil é executar dotnet restore .

De acordo com a documentação do Package Restore , ele também é acionado por nuget restore . De qualquer forma, executar dotnet restore resulta em um erro parcial:

[…]/eto-test/eto-test.Desktop/eto-test.Desktop.fsproj(57,3): error MSB4020: The value "" of the "Project" attribute in element <Import> is invalid.
[…]/eto-test/eto-test.Desktop/eto-test.Desktop.fsproj : warning NU1503: Skipping restore for project '[…]/eto-test/eto-test.Desktop/eto-test.Desktop.fsproj'. The project file may be invalid or missing targets required for restore. [[…]/eto-test/eto-test.sln]
[…]

Isso parece levar a problemas ao executar msbuild :

/usr/lib/mono/fsharp/Microsoft.FSharp.Targets(181,9): error MSB4062: The "FSharpEmbedResXSource" task could not be loaded from the assembly /usr/lib/mono/fsharp/FSharp.Build.dll.  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. [[…]/eto-test/eto-test.Desktop/eto-test.Desktop.fsproj]
Done Building Project "[…]/eto-test/eto-test.Desktop/eto-test.Desktop.fsproj" (default targets) -- FAILED.
Done Building Project "[…]/eto-test/eto-test.sln" (default targets) -- FAILED.

Build FAILED.

"[…]/eto-test/eto-test.sln" (default target) (1) ->
"[…]/eto-test/eto-test.Desktop/eto-test.Desktop.fsproj" (default target) (3) ->
(GenerateFSharpTextResources target) -> 
  /usr/lib/mono/fsharp/Microsoft.FSharp.Targets(181,9): error MSB4062: The "FSharpEmbedResXSource" task could not be loaded from the assembly /usr/lib/mono/fsharp/FSharp.Build.dll.  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. [[…]/eto-test/eto-test.Desktop/eto-test.Desktop.fsproj]

    0 Warning(s)
    1 Error(s)

De acordo com a documentação do Package Restore, ele é acionado também pela restauração do nuget.

nuget restore precisa de argumentos para que o diretório de restauração e o arquivo de projeto funcionem, é disso que estou falando, você não pode executá-lo sem eles (a menos que tenha sido alterado por acaso).

Parece que o problema no meu caso é que $(FSharpTargetsPath) está vazio. Não é surpreendente, pois o arquivo .fsproj , ao definir essa variável, parece supor que o Visual Studio está instalado:

<Choose>
  <When Condition="'$(VisualStudioVersion)' == '11.0'">
    <PropertyGroup Condition=" '$(FSharpTargetsPath)' == '' AND Exists('$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets') ">
      <FSharpTargetsPath>$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath>
    </PropertyGroup>
  </When>
  <Otherwise>
    <PropertyGroup Condition=" '$(FSharpTargetsPath)' == '' AND Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets') ">
      <FSharpTargetsPath>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets</FSharpTargetsPath>
    </PropertyGroup>
  </Otherwise>
</Choose>

sim, pode ser uma boa ideia como um caso de teste executar em uma vm limpa com dotnet core e mono para ver o que você realmente precisa para construir isso.

@cra0zy dotnet restore não suporta packages.config, que é necessário para os modelos F#. No entanto, acabei de perceber que os modelos no nuget não foram atualizados para 2.4.1 (eles estão em 2.4.0), que removi o requisito packages.config, pois as ferramentas do F# agora o suportam corretamente.

Deve ser corrigido com #1104.

Obrigado por relatar o problema!

Esta página foi útil?
0 / 5 - 0 avaliações

Questões relacionadas

Sanae6 picture Sanae6  ·  4Comentários

Jojatekok picture Jojatekok  ·  33Comentários

jzlhll picture jzlhll  ·  14Comentários

Krakean picture Krakean  ·  6Comentários

Xisrith picture Xisrith  ·  5Comentários