talboren
(Tal Borenstein)
January 29, 2020, 4:04pm
1
An interesting buggy behavior I found while persistence execution scripts did not run when publishing my dotnet application using the /p:PublishSingleFile attribute:
opened 12:17PM - 28 Jan 20 UTC
<!--
More information on our issue management policies can be found here: htt… ps://aka.ms/aspnet/issue-policies
Please keep in mind that the GitHub issue tracker is not intended as a general support forum, but for reporting non-security bugs and feature requests.
If you believe you have an issue that affects the SECURITY of the platform, please do NOT create an issue and instead email your issue details to secure@microsoft.com. Your report may be eligible for our [bug bounty](https://www.microsoft.com/en-us/msrc/bounty-dot-net-core) but ONLY if it is reported through email.
For other types of questions, consider using [StackOverflow](https://stackoverflow.com).
-->
### Describe the bug
My application is using NServiceBus as the implementation to the Service Bus pattern.
NServiceBus generates several SQL scripts for its persistence mechanism and then executes those script when starting up (to create the necessary tables), these scripts are generated by an MSBuild task at compile time.
The scripts are generated in to a folder called NServiceBus.Persistence.Sql which then has a few more folders for the relevant database types (e.g: MsSqlServer, MySql etc..) as you can see here:

NServiceBus will then search for the specific files under NServiceBus.Persistence.Sql directory at the parent app directory - at this point everything seems to be working fine.
The problem begins when moving to a "Single File Executable" with the "PublishSingleFile" parameter set.
After reading https://github.com/dotnet/designs/blob/master/accepted/single-file/extract.md it seems like I understood the way the extraction mechanism works but it seems like there's a buggy situation where folders that contains folders inside get extracted faulty (when looking at "/var/tmp/.net/AppName/bov1qdmu.xn3/":

and the following error message appears:
> appname_1 | 2020-01-27 16:49:54.790 INFO Directory '/var/tmp/.net/AppName/bov1qdmu.xn3/NServiceBus.PersistenceSql/MySql/Sagas' not found so no saga creation scripts will be executed.
### To Reproduce
<!--
What steps can we follow to reproduce the issue?
We ❤ code! Include a complete code listing or point us to a minimalistic GitHub repo.
``` C#
Console.WriteLine("Hello, World!");
```
Got Exceptions? Include both the message and the stack trace
-->
Having a project with NServiceBus using persistence mechanism, reproduce this issue easily by just switching from:
`RUN dotnet publish AppName.csproj -c Release -r linux-musl-x64 -o /app`
To
`RUN dotnet publish AppName.csproj -c Release -r linux-musl-x64 /p:PublishSingleFile=true -o /app`
### Further technical details
- ASP.NET Core version: **mcr.microsoft.com/dotnet/core/runtime-deps:3.1-alpine** (3.1.101),
- Include the output of `dotnet --info`: **No runtime is installed, app is self-contained**
- The IDE (VS / VS Code/ VS4Mac) you're running on, and it's version: **Microsoft Visual Studio Professional 2019 Version 16.4.3**
Kyle_Baley
(Kyle Baley)
January 29, 2020, 8:57pm
2
Hi Tal,
Thanks for linking that here. We’ll keep an eye on it. At first glance, it’s likely they aren’t parsing paths correctly on Linux. Possibly a \
vs. /
thing.
– Kyle
talboren
(Tal Borenstein)
February 11, 2020, 8:10am
3
Hey Kyle,
Please see swaroop-sridhar response at Directory separator for TargetPath is not normalized · Issue #10627 · dotnet/sdk · GitHub since the problem is caused both due to NServiceBus and dotnet SDK.
Thanks!
Hi Tal
We did Simplify the targets file by bording · Pull Request #404 · Particular/NServiceBus.Persistence.Sql · GitHub as part of the v5 release that should address this issue. Can you give it a go and report back?
Regards
Daniel