Ask HN: Developing .NET on Windows but deploying to Linux – common issues?
I develop a Blazor Server app on Windows but deploy it to Linux servers (mostly for cost reasons).
Quite often everything works locally but fails on Linux. In many cases it turns out to be things like case-sensitive paths or filesystem differences.
I'm curious how others handle this workflow.
Do you also develop on Windows and deploy to Linux? What kinds of issues did you encounter?
(
7 comments
| on HN
)
I can run it in WSL, but since my development happens on Windows I have to copy the build output into the WSL environment and run it there. I automated it a bit, but it still adds noticeable overhead and slows down the feedback loop.
So I usually only test there when I suspect a Linux-specific issue (case sensitivity, paths, permissions, etc.).
I tried running it in WSL, but my usual workflow is still centered around Windows tooling, so it adds a bit of friction to the inner dev loop.
Maybe moving more of the build pipeline into WSL would actually be the cleaner approach long term.
There are things that can help with filesystem differences though, if you're not using them already look under the System.IO namespace
Path.Combine will combine path segments using the native directory separator either `/` or `\`.
Path.GetTempFileName will create a temporary file on disk so you don't need to know if that's `/tmp` or `C:\whereverwindowsputsit\`
Mostly everything just works when coding on Windows and deploying to Linux, I think it is only the filesystem differences that ever cause problems and even then it's down to coding mistakes.
Linux just makes them visible much earlier.
I'll definitely take another look at the System.IO helpers you mentioned to avoid some of that.
Are there any other common pitfalls you’ve seen when running .NET apps on Linux that are easy to overlook?
If you're using classes under the System.Drawing namespace then a lot of functionality is missing in Linux, but I don't know much about that. The 3rd party ImageSharp library fills some of the gap and is just generally awesome.
Other than that, I'm sure there's niche things but nothing is coming to mind!