Program won’t run with just .net runtime [Answered]

So my program that I published and is targeting .net 6 won’t run when the pc has just .net 6 runtime installed. It should be able to run with just this right? It doesn’t start working until I also install the .net 6 sdk, which it shouldn’t need right? Am I publishing my program incorrectly to cause this or what could it be?
21 Replies
Angius
Angius3y ago
Well, how did you publish it?
primetime43
primetime43OP3y ago
Through Vs as single file. But it seems the issue was that the runtime only contained the .netcore app runtime. Once I installed the sdk, it added the aspnetcore and windows desktop runtime Not sure why windowsdesktop runtime wouldn’t be included in the runtime install, but ya seems that’s what was missing
Angius
Angius3y ago
There's only one runtime There's no special ASP.NET runtime, or WPF runtime
primetime43
primetime43OP3y ago
primetime43
primetime43OP3y ago
@Angius this says otherwise
Angius
Angius3y ago
Huh
primetime43
primetime43OP3y ago
.Net runtimes installed:
Klarth
Klarth3y ago
ASP.NET Core / Desktop require a lot of additional libraries, so it doesn't make sense to ship them with every .NET runtime install. The Desktop libraries are Windows-specific. You can look at the installers here: https://dotnet.microsoft.com/en-us/download/dotnet/6.0
primetime43
primetime43OP3y ago
Gotcha, so it needing the sdk is normal? Or is there a way I can publish it to not need it? Cause there’s libs I obv can’t not use
Angius
Angius3y ago
You can try $selfcontained
MODiX
MODiX3y ago
See $singlefile
Angius
Angius3y ago
$singlefile
MODiX
MODiX3y ago
dotnet publish -c Release -r <runtime identifier> -p:PublishSingleFile=true Use of -r|--runtime implies --self-contained true. Add --self-contained false to publish as runtime-dependent. -r ... and -p:PublishSingleFile=true can be moved to .csproj as the following properties:
<RuntimeIdentifier>runtime identifier</RuntimeIdentifier>
<PublishSingleFile>true</PublishSingleFile>
<RuntimeIdentifier>runtime identifier</RuntimeIdentifier>
<PublishSingleFile>true</PublishSingleFile>
but to target multiple RIDs, you have to use dotnet publish with the -r option for each RID. You can also add -p:IncludeNativeLibrariesForSelfExtract=true to include native libraries (like Common Language Runtime dlls) in the output executable. https://docs.microsoft.com/en-us/dotnet/core/deploying/single-file https://docs.microsoft.com/en-us/dotnet/core/rid-catalog https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-publish
Create a single file for application deployment - .NET
Learn what single file application is and why you should consider using this application deployment model.
.NET Runtime Identifier (RID) catalog
Learn about the Runtime Identifier (RID) and how RIDs are used in .NET.
primetime43
primetime43OP3y ago
That’s what I used Hmm
Angius
Angius3y ago
Just with the self-contained option You created a single file, IIRC You can do that + embed the necessary runtime
primetime43
primetime43OP3y ago
Single file along with self-contained
Klarth
Klarth3y ago
I think you still need to install the .NET Desktop Runtime if you do singlefile, self-contained with desktop. I'm not sure though. Assuming you're publishing a WinForms/WPF app.
primetime43
primetime43OP3y ago
Yes Ok ty
qqdev
qqdev3y ago
I feel your pain Had the same issue Nothing worked (was a very simple project) And never got it working ;D self-contained + single file (WPF)
phaseshift
phaseshift3y ago
That's not true, there are three runtime packages/installers
Accord
Accord3y ago
✅ This post has been marked as answered!
Want results from more Discord servers?
Add your server