Uno.Wasm.Bootstrap icon indicating copy to clipboard operation
Uno.Wasm.Bootstrap copied to clipboard

Some `*.pdb` files are copied to `dist` even when they shouldn't

Open mmarinchenko opened this issue 3 years ago • 6 comments

This issue is spin-off of #393.


Steps to reproduce (PowerShell)

dotnet new -i Uno.ProjectTemplates.Dotnet
dotnet new unoapp -o UnoWasmApp -wasm=true -ios=false -android=false -macos=false -skia-wpf=false -skia-gtk=false -st=false

cd .\UnoWasmApp\UnoWasmApp.Wasm\
dotnet publish UnoWasmApp.Wasm.csproj -c Release -r browser-wasm -p:WasmShellDistPath=..\release
ls ..\release -recurse -include *.pdb

    Directory: D:\VSProjects\UnoWasmApp\release\package_41fdcfabcfdb4bcf5ddae83c7e373df9406530b2\managed

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a---          03.08.2020    19:50           1936 Uno.Wasm.TimezoneData.pdb

The Uno.Wasm.TimezoneData.* files have different (old) LastWriteTime - I guess this is important thing. Other files in package_* folder always have current time.

Try to ensure that we really don't want *.pdb files in output directory:

dotnet publish UnoWasmApp.Wasm.csproj -c Release -r browser-wasm -p:WasmShellDistPath=..\release_1 -p:MonoRuntimeDebuggerEnabled=false -p:DebugType=none -p:DebugSymbols=false -p:DefineDebug=false
ls ..\release_1 -recurse -include *.pdb

    Directory: D:\VSProjects\UnoWasmApp\release_1\package_41fdcfabcfdb4bcf5ddae83c7e373df9406530b2\managed

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a---          03.08.2020    19:50           1936 Uno.Wasm.TimezoneData.pdb

No luck.


Now if we update the project:

-    <TargetFramework>netstandard2.0</TargetFramework>
+    <TargetFramework>net5.0</TargetFramework>

-    <PackageReference Include="Uno.Wasm.Bootstrap" Version="1.3.4" />
-    <PackageReference Include="Uno.Wasm.Bootstrap.DevServer" Version="1.3.4" />
+    <PackageReference Include="Uno.Wasm.Bootstrap" Version="2.1.0" />
+    <PackageReference Include="Uno.Wasm.Bootstrap.DevServer" Version="2.1.0" />
+    <PackageReference Include="Microsoft.Windows.Compatibility" Version="5.0.2" />

We get much more *.pdb files (but not as much as with Debug build):

dotnet publish UnoWasmApp.Wasm.csproj -c Release -r browser-wasm -p:WasmShellDistPath=..\release_2 -p:MonoRuntimeDebuggerEnabled=false -p:DebugType=none -p:DebugSymbols=false -p:DefineDebug=false
ls ..\release_2 -recurse -include *.pdb

    Directory: D:\VSProjects\UnoWasmApp\release_2\package_ef12460a6faaa91f8871a005c80ada6e9255e021\managed

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a---          03.06.2021    22:01           8916 System.Collections.Concurrent.pdb
-a---          03.06.2021    22:01          24792 System.Collections.Immutable.pdb
-a---          03.06.2021    22:01           4880 System.Collections.NonGeneric.pdb
-a---          03.06.2021    22:01           6820 System.Collections.pdb
-a---          03.06.2021    22:01           5268 System.Collections.Specialized.pdb
-a---          03.06.2021    22:01            892 System.ComponentModel.pdb
-a---          03.06.2021    22:01           3204 System.ComponentModel.Primitives.pdb
-a---          03.06.2021    22:01          51912 System.ComponentModel.TypeConverter.pdb
-a---          03.06.2021    22:01           5448 System.Console.pdb
-a---          03.06.2021    22:01           4676 System.Drawing.Primitives.pdb
-a---          03.06.2021    22:01           6264 System.IO.FileSystem.pdb
-a---          03.06.2021    22:01         246444 System.Linq.Expressions.pdb
-a---          03.06.2021    22:01          21396 System.Linq.pdb
-a---          03.06.2021    22:01           6288 System.Linq.Queryable.pdb
-a---          03.06.2021    22:01          67304 System.Net.Http.pdb
-a---          03.06.2021    22:01           1792 System.Net.Primitives.pdb
-a---          03.06.2021    22:01           2884 System.Net.Security.pdb
-a---          03.06.2021    22:01           7628 System.ObjectModel.pdb
-a---          03.06.2021    22:01         659600 System.Private.CoreLib.pdb
-a---          03.06.2021    22:01          29948 System.Private.Uri.pdb
-a---          03.06.2021    22:01         318460 System.Private.Xml.pdb
-a---          03.06.2021    22:01            512 System.Runtime.CompilerServices.Unsafe.pdb
-a---          03.06.2021    22:01           2368 System.Runtime.InteropServices.RuntimeInformation.pdb
-a---          03.06.2021    22:01          47612 System.Text.RegularExpressions.pdb
-a---          03.06.2021    22:01           4244 System.Web.HttpUtility.pdb
-a---          03.06.2021    22:01          37140 Uno.Core.pdb
-a---          03.06.2021    22:01           2000 Uno.Diagnostics.Eventing.pdb
-a---          03.06.2021    22:01          10704 Uno.Extensions.Logging.WebAssembly.Console.pdb
-a---          03.06.2021    22:01          24180 Uno.Foundation.pdb
-a---          03.06.2021    22:01          13256 Uno.Foundation.Runtime.WebAssembly.pdb
-a---          03.06.2021    22:01          77656 Uno.pdb
-a---          03.06.2021    22:01         440404 Uno.UI.FluentTheme.pdb
-a---          03.06.2021    22:01        1847140 Uno.UI.pdb
-a---          03.06.2021    22:01          10676 Uno.UI.Runtime.WebAssembly.pdb
-a---          03.06.2021    22:01          11280 Uno.UI.Toolkit.pdb
-a---          03.06.2021    22:01           7612 Uno.Wasm.TimezoneData.pdb
-a---          03.06.2021    22:01          32832 Uno.Xaml.pdb

mmarinchenko avatar Jun 03 '21 17:06 mmarinchenko

Thanks for the update. Can you check if the files are actually downloaded when opening the app?

jeromelaban avatar Jun 03 '21 17:06 jeromelaban

In Release mode they are not requested from the server:

image


And as I can see are not served: https://github.com/unoplatform/Uno.Wasm.Bootstrap/blob/main/src/Uno.Wasm.Bootstrap.Cli/Server/Startup.cs#L109-#L112

GitHub
A simple nuget package to run C# code in a WASM-compatible browser - unoplatform/Uno.Wasm.Bootstrap

mmarinchenko avatar Jun 03 '21 18:06 mmarinchenko

Ok, so they are only copied to the dist folder. It could be related to how the linker is configured, good to know. Thanks!

jeromelaban avatar Jun 04 '21 11:06 jeromelaban

I guess the following files should also not be copied to dist:

  • corebindings.c
  • driver.c
  • emcc-default.rsp
  • emcc-props.json
  • pinvoke.h
  • pinvoke.c

mmarinchenko avatar Feb 20 '22 21:02 mmarinchenko

7.0.x introduced more unnecessary files in the dist directory. We have to add the following task to Wasm head to get around this:

  <Target Name="DeleteUnnecessaryFiles" AfterTargets="Publish" Condition="'$(Configuration)'=='Release'">
    <ItemGroup>
      <_FilesToDelete Remove="@(_FilesToDelete)" />
      <_FilesToDelete Include="$(PublishDir)\**\obj\*.*" />
      <_FilesToDelete Include="$(PublishDir)\**\emcc-*" />
      <_FilesToDelete Include="$(PublishDir)\**\package.json" />
      <_FilesToDelete Include="$(PublishDir)\**\runtime.js" />
      <_FilesToDelete Include="$(PublishDir)\**\*.c" />
      <_FilesToDelete Include="$(PublishDir)\**\*.h" />
      <_FilesToDelete Include="$(PublishDir)\**\*.lib.js" />
      <_FilesToDelete Include="$(PublishDir)\**\*.pdb" />
      <_FilesToDelete Include="$(PublishDir)\**\*.runtime.json" />
      <_FilesToDelete Include="$(PublishDir)\**\*.symbols" />
      <_FilesToDelete Include="$(PublishDir)\**\*.ts" />
      <_FilesToDelete Include="$(PublishDir)\**\*.txt" />
    </ItemGroup>
    <Delete Files="@(_FilesToDelete)">
      <Output TaskParameter="DeletedFiles" ItemName="_DeletedFiles" />
    </Delete>
    <Message Importance="high" Condition="'@(_DeletedFiles-&gt;Count())'&lt;='0'" Text="$(PublishDir): no unnecessary files deleted." />
    <Message Importance="high" Condition="'@(_DeletedFiles-&gt;Count())'&gt;'0'" Text="$(PublishDir): unnecessary files deleted (@(_DeletedFiles->'%(FileName)%(Extension)'))." />
  </Target>

Output when publishing:

<...>\WasmHead\obj\Release\net6.0\PubTmp\Out\: unnecessary files deleted (uno-bootstrap.d.ts;uno-bootstrap.js;emcc-compile.rsp;emcc-default.rsp;emcc-link.rsp;emcc-props.json;package.json;runtime.js;corebindings.c;driver.c;pinvoke.c;gc-common.h;pinvoke.h;wasm-config.h;pal_random.lib.js;WasmHead.staticwebassets.runtime.json;dotnet.js.symbols;dotnet-legacy.d.ts;dotnet.d.ts;uno-assets.txt).

Which means the following list:

  • obj\uno-bootstrap.d.ts
  • obj\uno-bootstrap.js
  • corebindings.c
  • dotnet.d.ts
  • dotnet.js.symbols
  • dotnet-legacy.d.ts
  • driver.c
  • emcc-compile.rsp
  • emcc-default.rsp
  • emcc-link.rsp
  • emcc-props.json
  • gc-common.h
  • package.json
  • pal_random.lib.js
  • pinvoke.c
  • pinvoke.h
  • runtime.js
  • uno-assets.txt
  • wasm-config.h
  • WasmHead.staticwebassets.runtime.json

mmarinchenko avatar Jan 21 '23 09:01 mmarinchenko

Some changes for this have been introduced in 8.0-dev builds regarding this particular issue.

jeromelaban avatar Jan 25 '23 21:01 jeromelaban