Reputation: 1085
To make distribution of my .NET Core
app easier, I wish to bundle the installer for it in my installation process and silently install it together with my application. Windows already comes with the .NET Framework
so it should be possible to write a .NET script that does this.
I tried to use a provided PS script: https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-install-script but sadly even after successfully running it and finishing without errors the dotnet
command was not found. I manually added to PATH C:\Users\user\AppData\Local\Microsoft\dotnet
but it seems that was not enough.
Has something like this been done before? What exactly does the official .NET Core installer does besides putting files in \AppData\Local\Microsoft\dotnet
and setting environment variables? I am using NSIS
for my installer.
Upvotes: 0
Views: 712
Reputation: 14567
You see, having to install anything onto a system sounds like pain, when .net core actually allows you to bundle everything your app needs (and only that, I believe) as the comments above suggest.
In spirit of Keeping It Stupidly Simple I would suggest you consider that option and not reinvent the wheel here.
I feel like I am hijacking an answer here, but here's the documentation and I believe all you need to do is add one command line to your build:
dotnet publish -c Release -r <RID> --self-contained true
For more inspiration see https://learn.microsoft.com/en-us/dotnet/core/deploying/#self-contained-deployments-scd
For the sake of completeness I'll suggest you check out Chocolatey as it's basically a package manager for Windows that you can run pretty easily. But again, I'd advise you against writing custom scripts when Microsoft has already taken care of it.
Upvotes: 2
Reputation: 5496
You can get inspiration from a .NET tool I co-wrote with Joseph Woodward here: https://github.com/JosephWoodward/DotNetInstallSdkGlobalTool/tree/master/src/DotNetInstallSdk
The technique we used was to download the release metadata json (Blogged here) and then download and run the appropriate installer for the platform and version.
Edit: Others have pointed out the self-contain deployment option, this is more suitable for the problem you are trying to solve.
Upvotes: 0