Snapcraft fails when snapping .net core console application

Bug #1812500 reported by Peter Szucs
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Snapcraft
Invalid
Undecided
Sergio Schvezov

Bug Description

I have a solution with one project called 'console' that simply writes 'Hello World' to the console. After building the application I get an error like this (I included the output from the successful build as well)

Welcome to .NET Core!
---------------------
Learn more about .NET Core @ https://aka.ms/dotnet-docs. Use dotnet --help to see available commands or go to https://aka.ms/dotnet-cli-docs.

Telemetry
--------------
The .NET Core tools collect usage data in order to improve your experience. The data is anonymous and does not include command-line arguments. The data is collected by Microsoft and shared with the community.
You can opt out of telemetry by setting a DOTNET_CLI_TELEMETRY_OPTOUT environment variable to 1 using your favorite shell.
You can read more about .NET Core tools telemetry @ https://aka.ms/dotnet-cli-telemetry.

Configuring...
-------------------
A command is running to initially populate your local package cache, to improve restore speed and enable offline access. This command will take up to a minute to complete and will only happen once.
Decompressing 100% 6489 ms
Expanding 100% 7774 ms
Microsoft (R) Build Engine version 15.5.180.51428 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restoring packages for /root/build_ridersnap/parts/ridersnap/build/console/console.csproj...
  Generating MSBuild file /root/build_ridersnap/parts/ridersnap/build/console/obj/console.csproj.nuget.g.props.
  Generating MSBuild file /root/build_ridersnap/parts/ridersnap/build/console/obj/console.csproj.nuget.g.targets.
  Restore completed in 148.64 ms for /root/build_ridersnap/parts/ridersnap/build/console/console.csproj.
  console -> /root/build_ridersnap/parts/ridersnap/build/console/bin/Release/netcoreapp2.0/console.dll

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

Time Elapsed 00:00:03.07
/root/build_ridersnap/parts/ridersnap/dotnet/sdk/dotnet publish -c Release -o /root/build_ridersnap/parts/ridersnap/install --self-contained -r linux-x64
Microsoft (R) Build Engine version 15.5.180.51428 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restoring packages for /root/build_ridersnap/parts/ridersnap/build/console/console.csproj...
  Installing runtime.linux-x64.Microsoft.NETCore.DotNetAppHost 2.0.0.
  Installing runtime.linux-x64.Microsoft.NETCore.DotNetHostResolver 2.0.0.
  Installing runtime.linux-x64.Microsoft.NETCore.DotNetHostPolicy 2.0.0.
  Installing runtime.linux-x64.Microsoft.NETCore.App 2.0.0.
  Restore completed in 6.99 sec for /root/build_ridersnap/parts/ridersnap/build/console/console.csproj.
  console -> /root/build_ridersnap/parts/ridersnap/build/console/bin/Release/netcoreapp2.0/linux-x64/console.dll
  console -> /root/build_ridersnap/parts/ridersnap/install/
Sorry, an error occurred in Snapcraft:
Traceback (most recent call last):
  File "/usr/bin/snapcraft", line 9, in <module>
    load_entry_point('snapcraft==2.43.1', 'console_scripts', 'snapcraft')()
  File "/usr/lib/python3/dist-packages/click/core.py", line 716, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 696, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 1060, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3/dist-packages/click/core.py", line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3/dist-packages/click/core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/snapcraft/cli/lifecycle.py", line 136, in snap
    project = _execute(steps.PRIME, parts=[], **kwargs)
  File "/usr/lib/python3/dist-packages/snapcraft/cli/lifecycle.py", line 35, in _execute
    lifecycle.execute(step, project_config, parts)
  File "/usr/lib/python3/dist-packages/snapcraft/internal/lifecycle/_runner.py", line 90, in execute
    executor.run(step, part_names)
  File "/usr/lib/python3/dist-packages/snapcraft/internal/lifecycle/_runner.py", line 194, in run
    self._handle_step(part_names, part, step, current_step, cli_config)
  File "/usr/lib/python3/dist-packages/snapcraft/internal/lifecycle/_runner.py", line 208, in _handle_step
    getattr(self, "_run_{}".format(current_step.name))(part)
  File "/usr/lib/python3/dist-packages/snapcraft/internal/lifecycle/_runner.py", line 261, in _run_build
    self._run_step(step=steps.BUILD, part=part, progress="Building")
  File "/usr/lib/python3/dist-packages/snapcraft/internal/lifecycle/_runner.py", line 327, in _run_step
    getattr(part, step.name)()
  File "/usr/lib/python3/dist-packages/snapcraft/internal/pluginhandler/__init__.py", line 523, in build
    self._do_build()
  File "/usr/lib/python3/dist-packages/snapcraft/internal/pluginhandler/__init__.py", line 545, in _do_build
    self._runner.build()
  File "/usr/lib/python3/dist-packages/snapcraft/internal/pluginhandler/_runner.py", line 97, in build
    "override-build", self._override_build_scriptlet, self._builddir
  File "/usr/lib/python3/dist-packages/snapcraft/internal/pluginhandler/_runner.py", line 162, in _run_scriptlet
    scriptlet_name, function_call.strip()
  File "/usr/lib/python3/dist-packages/snapcraft/internal/pluginhandler/_runner.py", line 218, in _handle_builtin_function
    function(**function_args)
  File "/usr/lib/python3/dist-packages/snapcraft/plugins/dotnet.py", line 175, in build
    appname = os.path.join(self.installdir, self._get_appname())
  File "/usr/lib/python3.5/posixpath.py", line 89, in join
    genericpath._check_arg_types('join', a, *p)
  File "/usr/lib/python3.5/genericpath.py", line 143, in _check_arg_types
    (funcname, s.__class__.__name__)) from None
TypeError: join() argument must be str or bytes, not 'NoneType'
We would appreciate it if you created a bug report at
https://launchpad.net/snapcraft/+filebug with the above text included.
Stopping local:snapcraft-weekly-first-cod

----
Contents of my snapcraft.yaml:

name: ridersnap
version: '0.1'
summary: Woo
description: Hoo
grade: devel
confinement: devmode

parts:
  ridersnap:
    plugin:
      dotnet

apps:
  ridersnap:
    command: ridersnap

----
Project structure:
ridersnap (solution folder)
  ridersnap.sln
  snapcraft.yaml
  console (project folder)
    console.csproj
    Program.cs

description: updated
description: updated
Changed in snapcraft:
milestone: none → 3.5
Revision history for this message
Sergio Schvezov (sergiusens) wrote :
Changed in snapcraft:
assignee: nobody → Tony Simpson (tonysimpson)
Revision history for this message
Sergio Schvezov (sergiusens) wrote :

discard comment #1, wrong bug

Changed in snapcraft:
assignee: Tony Simpson (tonysimpson) → Sergio Schvezov (sergiusens)
Revision history for this message
Sergio Schvezov (sergiusens) wrote :
Download full text (4.3 KiB)

Mind trying with my slightly modified yaml to trigger snapcraft 3.0 behavior? (setting a base) and using the snapcraft snap instead?

sergiusens@gotham:~/projects$ dotnet new console -n ridersnap
The template "Console Application" was created successfully.

Processing post-creation actions...
Running 'dotnet restore' on ridersnap/ridersnap.csproj...
  Restore completed in 145,06 ms for /home/sergiusens/projects/ridersnap/ridersnap.csproj.

Restore succeeded.

sergiusens@gotham:~/projects$ cd ridersnap/
# Changed the target in ridersnap.csproj to 2.0 considering that is what the plugin supports.
sergiusens@gotham:~/projects/ridersnap$ cat > .snapcraft.yaml <<EOF
> name: ridersnap
> base: core
> version: '0.1'
> summary: Woo
> description: Hoo
> grade: devel
> confinement: devmode
>
> parts:
> ridersnap:
> source: .
> plugin: dotnet
>
> apps:
> ridersnap:
> command: ridersnap
> EOF
sergiusens@gotham:~/projects/ridersnap$ snap list snapcraft
Name Version Rev Tracking Publisher Notes
snapcraft 3.4 2832 candidate canonical✓ classic

Then,
sergiusens@gotham:~/projects/ridersnap$ snapcraft --use-lxd
Using '.snapcraft.yaml': Project assets will be searched for from the 'snap' directory.
The LXD provider is offered as a technology preview for early adopters.
The command line interface, container names or lifecycle handling may change in upcoming releases.
Launching a container.
/snap/snapcraft/2832/lib/python3.5/site-packages/pylxd/models/operation.py:59: UserWarning: Attempted to set unknown attribute "location" on instance of "Operation"
  .format(key, self.__class__.__name__))
Waiting for cloud-init
...
status: done
error: no changes of type "auto-refresh" found
snap "core" has no updates available
snap "snapcraft" has no updates available
snap "core" has no updates available
Using '.snapcraft.yaml': Project assets will be searched for from the 'snap' directory.
Get:1 http://security.ubuntu.com/ubuntu xenial-security InRelease [109 kB]
Hit http://archive.ubuntu.com/ubuntu xenial InRelease
Get:2 http://archive.ubuntu.com/ubuntu xenial-updates InRelease [109 kB]
Get:3 http://archive.ubuntu.com/ubuntu xenial-backports InRelease [107 kB]
Fetched 325 kB in 0s (0 B/s)
Updating pull step for ridersnap (source changed)
Building ridersnap
/root/parts/ridersnap/dotnet/sdk/dotnet build -c Release
Microsoft (R) Build Engine version 15.5.180.51428 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restoring packages for /root/parts/ridersnap/build/ridersnap.csproj...
  Generating MSBuild file /root/parts/ridersnap/build/obj/ridersnap.csproj.nuget.g.props.
  Generating MSBuild file /root/parts/ridersnap/build/obj/ridersnap.csproj.nuget.g.targets.
  Restore completed in 127.28 ms for /root/parts/ridersnap/build/ridersnap.csproj.
  ridersnap -> /root/parts/ridersnap/build/bin/Release/netcoreapp2.0/ridersnap.dll

Build succeeded.
  ...

Read more...

Changed in snapcraft:
status: New → Incomplete
Revision history for this message
Sergio Schvezov (sergiusens) wrote :

At the time of this writing, --use-lxd is only available on snapcraft 3.4, currently in the candidate channel. You can omit the --use-lxd if you want snapcraft from the stable channel which default to the a different underlying build tech.

Revision history for this message
trampster (trampster) wrote :

I also am having this issue. Is there any work around or do I need to use the dump plugin instead?

Here is my yaml

name: ropuclient
base: core # core18 isnt supported
version: '0.1' # just for humans, typically '1.2+git' or '1.3.2'
summary: Ropu PTT client # 79 char long summary
description: |
  PTT (Push to Talk) client for the Ropu group PTT system

grade: devel # must be 'stable' to release into candidate/stable channels
confinement: devmode # use 'strict' once you have the right plugs and slots

parts:
  ropuclient:
    # See 'snapcraft plugins'
    source: .
    plugin: dotnet
    dotnet-runtime-version: 2.1.9 #defaults to dotnet 2.0

Revision history for this message
trampster (trampster) wrote :

My code is available here: https://github.com/trampster/Ropu if you want to reproduce this exactly

Revision history for this message
trampster (trampster) wrote :

My solutions is multiproject, that is there are two dotnet projects with a solution (.sln) file that ties them together.

This works with the dotnet tool but means that when you do dotnet publish -o InstallDir

The InstallDir will be a subdirectly of the project not at the root, I am guessing that this may be what is causing the dotnet plugin to crash.

Revision history for this message
mase (i-lp-f) wrote :

This works in 18.04

Fetched 176 kB in 0s (0 B/s)
Pulling ropu
Skipping build desktop-gnome-platform (already ran)
Building ropu
Skipping stage desktop-gnome-platform (already ran)
Staging ropu
Priming desktop-gnome-platform
Priming ropu
Files from the build host were migrated into the snap to satisfy dependencies that would otherwise not be met. This feature will be removed in a future release. If these libraries are needed in the final snap, ensure that the following are either satisfied by a stage-packages entry or through a part:
usr/lib/x86_64-linux-gnu/liblttng-ust-tracepoint.so.0
usr/lib/x86_64-linux-gnu/liblttng-ust.so.0
usr/lib/x86_64-linux-gnu/liburcu-bp.so.6
usr/lib/x86_64-linux-gnu/liburcu-cds.so.6
Snapping 'ropu' |
Snapped ropu_0.1_amd64.snap

Revision history for this message
Sergio Schvezov (sergiusens) wrote :

This bug has been marked as Invalid as it cannot be reproduced with the detail provided.
If this issue is still occurring feel free to open a new bug or re-open this one with enough detail (host OS, versions of software used, ...) to be able to reproduce.

Changed in snapcraft:
status: Incomplete → Invalid
Revision history for this message
trampster (trampster) wrote :

Sorry you didn't reproduce it, because I already switched to using the dump plugin because the dotnet one didn't work. I am using ubuntu 18.04

Revision history for this message
trampster (trampster) wrote :

I had given up waiting

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.