C
C#4mo ago
Elio

✅ Deploying WPF APP

Hi, i'm a bit lost with all the informations i've found like .net Framework, .net Runtime, Publish ClickOnce etc. I'd like to have some help to deploy my wpf app. To summ up i've developped an wpf app which : - Use .Net 8 Framework - Target Windows 10 .0.17763 This app is destinated to be set on a computer which isn't connected to Internet by using a usb key. So basically i thought about an installer which include the framework if needed to download and have all the stuff related to my app to set everything on the offline computer. How i'm am supposed to do ? Do i need to create an installer by myself or the publish tool on visual studio is supposed to work if well configured ?
23 Replies
Pobiega
Pobiega4mo ago
Okay, so you have a few options You could skip the need for an installer by just bundling the runtime with the application or you make an installer, maybe with WIX And a correction: .NET 8 is only .NET 8, no framework suffix added. .NET Framework is a different lineage and is the legacy version. If you decide to just bundle the runtime, thats what we call a "self contained application", and the dotnet publish command has all you need to do it
Elio
Elio4mo ago
okay then i just have to move the generated files in publish into the offline computer right ?
Pobiega
Pobiega4mo ago
yep You can read more about it here $singlefile
MODiX
MODiX4mo ago
dotnet publish -c Release -r <runtime identifier> -p:PublishSingleFile=true Use of -p:PublishSingleFile=true implies --self-contained true. Add --self-contained false to publish as runtime-dependent. -r RID and -p:PublishSingleFile=true can be moved to .csproj as the following properties:
<RuntimeIdentifier>RID</RuntimeIdentifier>
<PublishSingleFile>true</PublishSingleFile>
<RuntimeIdentifier>RID</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. You might want to instead publish your application compiled Ahead Of Time to native code, see $nativeaot for examples. Single file publishing | Runtime Identifier (RID) catalog | dotnet publish
Elio
Elio4mo ago
OK i'll look that and i have one more question, i didn't understand the diffrence between the .net 8 et the Framework, like is is possible that my app can't be run on the computer because the .NET Framework isn't with the correct version ?
Pobiega
Pobiega4mo ago
.NET 8 has nothing to do with .NET Framework different products, different lineage .NET 8 is a decendant from .NET 5, which came from .NET Core, which was a from-scratch rewrite of .NET Framework for multiplatform support. its an entirely different runtime
Elio
Elio4mo ago
ok so for my case if the computer do not have .NET 8 i can do the "self contained application" in order to avoid any compatibility issue right ?
Pobiega
Pobiega4mo ago
and the whole point of a self-contained build is that it contains the runtime itself yes you get a bigger executable as a tradeoff but thats usually not a problem
Elio
Elio4mo ago
ok that's it i understand now, the size do not matter for my case so i'm good with it. It will avoid me some setup to do if id do it this way 🙂 and last question is about the update, because in the future i would be able to update the wpf app even without connection on the computer by using usb key. Does ClickOnce could help me to do that or i should create my own console app to Copy Paste the good file ?
Pobiega
Pobiega4mo ago
ClickOnce is nothing but trouble, imho And if the app is self-contained and developed properly, storing user data in %appdata% etc, then just replacing the files should be enough
Elio
Elio4mo ago
ok i think i've understand the whole stuff i needed, to summ up i've 2 possibilities : First is to copy paste the publish file in the offline computer Second solution is to create an installer that will do this "copy paste" and add other stuff that if needed
Pobiega
Pobiega4mo ago
yep. you could quite easily write your own installer/updater for this or use WIX apparently WIX is quite difficult to get the hang of, but it does produce very professional installers
Elio
Elio4mo ago
ok you've helped me a lot cause i was really confused with clickonce and all these stuff in publish i will look for it cause i need something "pro" to have something user friendly in order to easily install and update my app
Pobiega
Pobiega4mo ago
But it can only update via the USB key, no?
Elio
Elio4mo ago
yes cause the computer is offline so every new version of the app will be updated on the offline computer from a usb key you mentionned something i didn't do on my app about the %appdata% that i will have to do in order to save the data correctly 😄
Pobiega
Pobiega4mo ago
I would maybe consider having an in-app "Update from USB key..." option then where you simply select the drive that has the program files on it, and it updates itself (using an elevator.exe approach) ie, a second executable. The main program first updates the elevator, then runs it, then shuts itself down, the elevator updates the main program and runs it this is how for example JetBrains Rider updates itself
Elio
Elio4mo ago
oh ok sound great to my case ! And does the selfcontained publish include all the .dll files and librairies stuffs ? so it only has to update the .exe ?
Pobiega
Pobiega4mo ago
singlefile + -p:IncludeNativeLibrariesForSelfExtract=true should include most if not all files I've never tried with WPF
Elio
Elio4mo ago
I will look. I won't bother you anymore you gave me everything i will do some more research on what you said thanks !
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
MODiX
MODiX4mo ago
dotnet publish -c Release -r <runtime identifier> -p:PublishSingleFile=true Use of -p:PublishSingleFile=true implies --self-contained true. Add --self-contained false to publish as runtime-dependent. -r RID and -p:PublishSingleFile=true can be moved to .csproj as the following properties:
<RuntimeIdentifier>RID</RuntimeIdentifier>
<PublishSingleFile>true</PublishSingleFile>
<RuntimeIdentifier>RID</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. You might want to instead publish your application compiled Ahead Of Time to native code, see $nativeaot for examples. Single file publishing | Runtime Identifier (RID) catalog | dotnet publish
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
MODiX
MODiX4mo ago
Use the /close command to mark a forum thread as answered