Skip to content

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

Closed

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>

Activity

  1. ghost added
    untriaged
    on Jul 31, 2023
  2. andriivitiv commented on Jul 31, 2023

    @andriivitiv
    Author

    Just made this changes in WasiApp.targets on my local installation and they did fix the problem.

    -    <_AppBundleDirForRunCommand Condition="'$(_AppBundleDirForRunCommand)' == ''">$([System.IO.Path]::Combine($(OutputPath), $(RuntimeIdentifier), 'AppBundle'))</_AppBundleDirForRunCommand>
    +    <_AppBundleDirForRunCommand Condition="'$(_AppBundleDirForRunCommand)' == '' And '$(UseArtifactsOutput)' != 'true'">$([System.IO.Path]::Combine($(OutputPath), $(RuntimeIdentifier), 'AppBundle'))</_AppBundleDirForRunCommand>
    +    <_AppBundleDirForRunCommand Condition="'$(_AppBundleDirForRunCommand)' == '' And '$(UseArtifactsOutput)' == 'true'">$([System.IO.Path]::Combine($(OutputPath), 'AppBundle'))</_AppBundleDirForRunCommand>

    Do you think this is the right way to fix this? I would like to make a PR.

  3. added
    arch-wasm
    os-wasi
    on Aug 1, 2023
  4. added this to the 8.0.0 milestone on Aug 1, 2023
  5. ghost removed
    untriaged
    on Aug 1, 2023
  6. radical commented on Aug 4, 2023

    @radical
    Member

    Just made this changes in WasiApp.targets on my local installation and they did fix the problem.

    -    <_AppBundleDirForRunCommand Condition="'$(_AppBundleDirForRunCommand)' == ''">$([System.IO.Path]::Combine($(OutputPath), $(RuntimeIdentifier), 'AppBundle'))</_AppBundleDirForRunCommand>
    +    <_AppBundleDirForRunCommand Condition="'$(_AppBundleDirForRunCommand)' == '' And '$(UseArtifactsOutput)' != 'true'">$([System.IO.Path]::Combine($(OutputPath), $(RuntimeIdentifier), 'AppBundle'))</_AppBundleDirForRunCommand>
    +    <_AppBundleDirForRunCommand Condition="'$(_AppBundleDirForRunCommand)' == '' And '$(UseArtifactsOutput)' == 'true'">$([System.IO.Path]::Combine($(OutputPath), 'AppBundle'))</_AppBundleDirForRunCommand>

    This wouldn't be the way to fix it. UseArtifactsOutput will control the $(OutputPath) part, not the rest of it. There is another property that control the RID being added to the path. I'll look for that.

  7. radical commented on Aug 4, 2023

    @radical
    Member

    Just made this changes in WasiApp.targets on my local installation and they did fix the problem.

    -    <_AppBundleDirForRunCommand Condition="'$(_AppBundleDirForRunCommand)' == ''">$([System.IO.Path]::Combine($(OutputPath), $(RuntimeIdentifier), 'AppBundle'))</_AppBundleDirForRunCommand>
    +    <_AppBundleDirForRunCommand Condition="'$(_AppBundleDirForRunCommand)' == '' And '$(UseArtifactsOutput)' != 'true'">$([System.IO.Path]::Combine($(OutputPath), $(RuntimeIdentifier), 'AppBundle'))</_AppBundleDirForRunCommand>
    +    <_AppBundleDirForRunCommand Condition="'$(_AppBundleDirForRunCommand)' == '' And '$(UseArtifactsOutput)' == 'true'">$([System.IO.Path]::Combine($(OutputPath), 'AppBundle'))</_AppBundleDirForRunCommand>

    This wouldn't be the way to fix it. UseArtifactsOutput will control the $(OutputPath) part, not the rest of it. There is another property that control the RID being added to the path. I'll look for that.

    Use $(AppendRuntimeIdentifierToOutputPath).

  8. ghost added
    in-pr
    on Aug 11, 2023
  9. ghost removed
    in-pr
    on Aug 14, 2023
  10. ghost locked as resolved and limited conversation to collaborators on Sep 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

arch-wasmarea-Infrastructure-monoos-wasi

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions