Repository navigation
Closed
Labels
arch-wasmWebAssembly architecturearea-Infrastructure-monoos-wasiRelated to WASI variant of arch-wasm
Milestone
Description
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.
-
Create a project using the
wasiconsoletemplate:dotnet new wasiconsole --output ./Wasi/WasiConsole
-
Create the Directory.Build.props file and set the
UseArtifactsOutputproperty totrue:echo -e '<Project>\n <PropertyGroup>\n <UseArtifactsOutput>true</UseArtifactsOutput>\n </PropertyGroup>\n</Project>' > ./Wasi/Directory.Build.props
-
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.
runtime/src/mono/wasi/build/WasiApp.targets
Line 148 in 2d1f6ec
| <_AppBundleDirForRunCommand Condition="'$(_AppBundleDirForRunCommand)' == ''">$([System.IO.Path]::Combine($(OutputPath), $(RuntimeIdentifier), 'AppBundle'))</_AppBundleDirForRunCommand> |
Metadata
Metadata
Assignees
Labels
arch-wasmWebAssembly architecturearea-Infrastructure-monoos-wasiRelated to WASI variant of arch-wasm
Activity
andriivitiv commentedon Jul 31, 2023
Just made this changes in WasiApp.targets on my local installation and they did fix the problem.
Do you think this is the right way to fix this? I would like to make a PR.
radical commentedon Aug 4, 2023
This wouldn't be the way to fix it.
UseArtifactsOutputwill 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.radical commentedon Aug 4, 2023
Use
$(AppendRuntimeIdentifierToOutputPath).[wasm] Respect `AppendRuntimeIdentifierToOutputPath`, and
[wasm] Respect `AppendRuntimeIdentifierToOutputPath`, and `UseArtifac…