Skip to content

Unable to run the wasi console template with UseArtifactsOutput=true #89744

Description

@andriivitiv

Description

An exception occurs when running the wasiconsole template via dotnet run with the UseArtifactsOutput property set to true.

Reproduction Steps

This steps assumes that the wasi-experimental workload and wasmtime are already installed.

  1. Create a project using the wasiconsole template:

    dotnet new wasiconsole --output ./Wasi/WasiConsole
  2. Create the Directory.Build.props file and set the UseArtifactsOutput property to true:

    echo -e '<Project>\n  <PropertyGroup>\n    <UseArtifactsOutput>true</UseArtifactsOutput>\n  </PropertyGroup>\n</Project>' > ./Wasi/Directory.Build.props
  3. Run the project:

    dotnet run --project ./Wasi/WasiConsole

Expected behavior

Expected output:

WasmAppHost --runtime-config /home/andrii/dev/Wasi/artifacts/bin/WasiConsole/debug_wasi-wasm/AppBundle/WasiConsole.runtimeconfig.json
Running: wasmtime run --dir . -- dotnet.wasm WasiConsole
Using working directory: /home/andrii/dev/Wasi/artifacts/bin/WasiConsole/debug_wasi-wasm/AppBundle
Hello, Wasi Console!

Actual behavior

Actual output:

Unhandled exception: System.ComponentModel.Win32Exception (2): An error occurred trying to start process '/home/andrii/.dotnet/dotnet' with working directory '/home/andrii/dev/Wasi/WasiConsole/bin/Debug/net8.0/wasi-wasm/AppBundle'. No such file or directory
   at System.Diagnostics.Process.ForkAndExecProcess(ProcessStartInfo startInfo, String resolvedFilename, String[] argv, String[] envp, String cwd, Boolean setCredentials, UInt32 userId, UInt32 groupId, UInt32[] groups, Int32& stdinFd, Int32& stdoutFd, Int32& stderrFd, Boolean usesTerminal, Boolean throwOnNoExec)
   at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)
   at Microsoft.DotNet.Cli.Utils.Command.Execute(Action`1 processStarted)
   at Microsoft.DotNet.Tools.Run.RunCommand.Execute()
   at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_0.<<BuildInvocationChain>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.DotNet.Cli.Parser.<>c__DisplayClass17_0.<<UseParseErrorReporting>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.CommandLineBuilderExtensions.<>c__DisplayClass11_0.<<UseHelp>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.CommandLineBuilderExtensions.<>c.<<UseSuggestDirective>b__17_0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.CommandLineBuilderExtensions.<>c__DisplayClass15_0.<<UseParseDirective>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.CommandLineBuilderExtensions.<>c__DisplayClass7_0.<<UseExceptionHandler>b__0>d.MoveNext()

Regression?

No response

Known Workarounds

Add the following to the .csproj file. Note: it won't work in Directory.Build.props nor Directory.Build.targets.

  <PropertyGroup Condition="'$(RuntimeIdentifier)' == 'wasi-wasm' And '$(UseArtifactsOutput)' == 'true'">
    <_AppBundleDirForRunCommand>$([System.IO.Path]::Combine($(ArtifactsPath), 'bin', $(ArtifactsProjectName), 'debug_wasi-wasm', 'AppBundle'))</_AppBundleDirForRunCommand>
  </PropertyGroup>

Configuration

.NET SDK:
 Version:   8.0.100-preview.6.23330.14
 Commit:    ba97796b8f

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  22.04
 OS Platform: Linux
 RID:         ubuntu.22.04-x64
 Base Path:   /home/andrii/.dotnet/sdk/8.0.100-preview.6.23330.14/

.NET workloads installed:
 [wasi-experimental]
   Installation Source: SDK 8.0.100-preview.6
   Manifest Version:    8.0.0-preview.6.23329.7/8.0.100-preview.6
   Manifest Path:       /home/andrii/.dotnet/sdk-manifests/8.0.100-preview.6/microsoft.net.workload.mono.toolchain.current/WorkloadManifest.json
   Install Type:        FileBased

Host:
  Version:      8.0.0-preview.6.23329.7
  Architecture: x64
  Commit:       5340be2ccc

Other information

I think this line should include $(RuntimeIdentifier) only when the UseArtifactsOutput property is set to false.

<_AppBundleDirForRunCommand Condition="'$(_AppBundleDirForRunCommand)' == ''">$([System.IO.Path]::Combine($(OutputPath), $(RuntimeIdentifier), 'AppBundle'))</_AppBundleDirForRunCommand>

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions