derskythe / WpfSettings

MIT License
27 stars 5 forks source link

How to get the UpdateLocation? #9

Closed KumG closed 9 months ago

KumG commented 9 months ago

In my .NET Framework 4.8 app, I'm using ApplicationDeployment.CurrentDeployment?.UpdateLocation to get the base URI of my server API.

In your example, the URL is hardcoded and passed in the constructor of PureManClickOnce...

Is there a way to get it ?

Thank you.

derskythe commented 9 months ago

@KumG Hi, there is no way to obtain dynamic UpdateLocation. When publishing the application in the .NET 4.8 framework there was a field "Update location" (if different than install path). Don't remember exact field names. This is hard-coded version of UpdateLocation

KumG commented 9 months ago

Ok, thank you. I absolutely need the URL, so I think I will stay with .NET Framework 4.8...

Are you 100% sure there is no way to get the URL ? I saw this but I don't know how it must be used: https://github.com/dotnet/deployment-tools/blob/main/Documentation/dotnet-mage/ApplicationDeployment.cs

Environment.GetEnvironmentVariable("ClickOnce_UpdateLocation")

KumG commented 9 months ago

I finally created a test app with :

var updateLocation = Environment.GetEnvironmentVariable("ClickOnce_UpdateLocation");
var isNetworkDeployed = Environment.GetEnvironmentVariable("ClickOnce_IsNetworkDeployed");
MessageBox.Show($"isNetworkDeployed: {isNetworkDeployed}, updateLocation:{updateLocation} ");

Then I published the app from Visual Studio to a folder, I copied the folder to my IIS website folder and installed it from there.

Now I get the updateLocation :

image