i have made wpf (c#) app that installs some of my apps to the windows, i am having issue with webapp when running .net hosting bundle repair.
my installer does this, amongst other things:
- Install .net hosting bundle 7.0.5
- Install IIS
- Copy app files to c:/inetpub/MyApp
- Give permission to that folder to IIS_IUSRS and DefaultAppPool
- Creates iis website localhost:8888
- Repairs .net hosting bundle (this step is necessary, since i get error "HTTP Error 500.19 - Internal Server Error" if i don't do it with c# process or manually)
- Restarts IIS
If i have no hosting bundle installed, this all works like a charm, but problem occurs when i have hosting bundle isntalled (in my case 7.0.5) and i try to repair through c#. My app just closes, i can't even get error in catch.
After installation (crash) i can manually opent hosting bundle .exe and click repair, or do it through cmd, than my website on iis works like it should Code for IIS installation is:
string file = @"dism.exe";
string arguments = $"/quiet /norestart /Online /Enable-Feature /FeatureName:IIS-WebServerRole /All";
Process process = new Process();
process.StartInfo.FileName = file;
process.StartInfo.Arguments = arguments;
process.StartInfo.UseShellExecute = false;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
process.Start();
process.WaitForExit();
I've tried:
- Run as admin
- Stop IIS before repairing .net hosting bundle and starting it again
- Execute repair with process()
- Execute repair with cmd (inside my wpf(c#) app)
- And so many combinations
my first code (that is working if .net hosting bundle is not installed, and my app does the install before creating iis site) is like this:
string file = @"./Source/dotnet-hosting-7.0.5-win.exe";
string arguments = $"/repair /quiet /norestart";
Process process = new Process();
process.StartInfo.FileName = file;
process.StartInfo.Arguments = arguments;
process.StartInfo.UseShellExecute = false;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
process.Start();
process.WaitForExit();
i have tried adding timeout
int timeoutMilliseconds = 10000;
if (!process.WaitForExit(timeoutMilliseconds))
i also tried giving full path to .net hosting bundle .exe file (even though it works when hosting bundle is not installed before my app starts install)
also this doen't work:
process.OutputDataReceived += (sender, e) =>
{
if (!string.IsNullOrWhiteSpace(e.Data))
Console.WriteLine(e.Data);
};
process.ErrorDataReceived += (sender, e) =>
{
if (!string.IsNullOrWhiteSpace(e.Data))
Console.WriteLine(e.Data);
};
basically, if there is .net hosting bundle installed before my wpf app is executed, repair doesn't work, i need to do it manually if i want my iis site to work
and btw this is the error i get before i do the repair
PS: I have asked ChatGPT 100000 questions, it's useless in this case