dotnet / dotnet-wasi-sdk

An SDK for building .NET projects as standalone WASI-compliant modules
MIT License
276 stars 12 forks source link

dotnet run tries to run wasm from wrong directory #23

Closed relcodedev closed 1 year ago

relcodedev commented 1 year ago

dotnet run with wasi.sdk enabled look for the wasm in the bin/Debug/net7.0/ folder instead of the bin/net7.0 folder:

image

If I run directory with wasmtime, I get :

wasmtime --tcplisten localhost:8080 --allow-precompiled --env ASPNETCORE_URLS=http://localhost:8080 --dir=. app.wasm

Can't load Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer.dll

Side Note: I had to include --allow-precompiled flag or it would not run.

The file is in the output.

{"Timestamp":"2023-06-02T16:45:45.0000000+00:00","Level":"Information","MessageTemplate":"Starting host"} {"Timestamp":"2023-06-02T16:45:45.0000000+00:00","Level":"Fatal","MessageTemplate":"Host failed unexpectedly","Exception":"System.IO.FileNotFoundException: \nFile name: 'Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer'\n at System.Reflection.Assembly.Load(AssemblyName assemblyRef, StackCrawlMark& stackMark, AssemblyLoadContext assemblyLoadContext)\n at System.Reflection.Assembly.Load(String assemblyString)\n at Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartManager.<>c.b__8_0(ApplicationPartAttribute name)\n at System.Linq.Enumerable.SelectArrayIterator2[[Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartAttribute, Microsoft.AspNetCore.Mvc.Core, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60],[System.Reflection.Assembly, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].MoveNext()\n at System.Collections.Generic.EnumerableHelpers.ToArray[Assembly](IEnumerable1 source, Int32& length)\n at System.Linq.Buffer1[[System.Reflection.Assembly, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]..ctor(IEnumerable1 source)\n at System.Linq.OrderedEnumerable1.<GetEnumerator>d__4[[System.Reflection.Assembly, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].MoveNext()\n at System.Linq.Enumerable.SelectManySingleSelectorIterator2[[System.Reflection.Assembly, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Reflection.Assembly, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].MoveNext()\n at System.Linq.Enumerable.ConcatIterator`1[[System.Reflection.Assembly, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].MoveNext()\n at Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartManager.PopulateDefaultParts(String entryAssemblyName)\n at Microsoft.Extensions.DependencyInjection.MvcCoreServiceCollectionExtensions.GetApplicationPartManager(IServiceCollection services, IWebHostEnvironment environment)\n at Microsoft.Extensions.DependencyInjection.MvcCoreServiceCollectionExtensions.AddMvcCore(IServiceCollection services)\n at Microsoft.Extensions.DependencyInjection.MvcServiceCollectionExtensions.AddControllersCore(IServiceCollection services)\n at Microsoft.Extensions.DependencyInjection.MvcServiceCollectionExtensions.AddControllers(IServiceCollection services)\n at Permissions.Service.Program.Main(String[] args)"}

relcodedev commented 1 year ago

I modified the Wasi.Sdk.Targets file

bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).wasm

to

bin\$(TargetFramework)\$(AssemblyName).wasm

and it works.

relcodedev commented 1 year ago

Non issue again. The Output configuration was specified which ignores $(configuration)