_moare
_moare
CC#
Created by _moare on 1/25/2023 in #help
❔ Deploy app to IIS
does anyone how i can make this deploy script for a .net application more reliable? When i run this script i often get a "Access to the path 'xxx' is denied" on the remove-item step, cause IIS still uses it. what would be the cleanest way to set it offline? Stopping the appPool would work, problem is i can't set a custom error page for that case.
Write-Host "Take app offline"
if(!(Test-Path "$($targetFolder)\app_offline.htm")) {
New-Item -Path "$($targetFolder)" -Name "app_offline.htm" -ItemType "file"
}

Write-Host "Delete..."
Start-Sleep -Seconds 5
Get-ChildItem -Path "$($targetFolder)" -Exclude app_offline.htm -Recurse -Force | Remove-Item -Recurse -Force -ErrorAction Stop

Start-Sleep -Seconds 1
Write-Host "Copy new files"
Expand-Archive -Path $sourceArchive -DestinationPath $targetFolder

Start-Sleep -Seconds 1
Write-Host "Take app online"
Remove-Item -Path "$($targetFolder)\app_offline.htm"
Write-Host "Take app offline"
if(!(Test-Path "$($targetFolder)\app_offline.htm")) {
New-Item -Path "$($targetFolder)" -Name "app_offline.htm" -ItemType "file"
}

Write-Host "Delete..."
Start-Sleep -Seconds 5
Get-ChildItem -Path "$($targetFolder)" -Exclude app_offline.htm -Recurse -Force | Remove-Item -Recurse -Force -ErrorAction Stop

Start-Sleep -Seconds 1
Write-Host "Copy new files"
Expand-Archive -Path $sourceArchive -DestinationPath $targetFolder

Start-Sleep -Seconds 1
Write-Host "Take app online"
Remove-Item -Path "$($targetFolder)\app_offline.htm"
2 replies
CC#
Created by _moare on 11/17/2022 in #help
❔ deserialize json object which should be an array
Hi, how can i deserialize a json-string like this, if i dont know how many "items" (item0, item1, item2) are there. If it would be an array, it would be no problem, but sadly it isn't. c#, .net7
{
"item0": {
"name": "Name1"
},
"item1": {
"name": "Name2"
},
"item2": {
"name": "Name3"
},
/*...*/
}
{
"item0": {
"name": "Name1"
},
"item1": {
"name": "Name2"
},
"item2": {
"name": "Name3"
},
/*...*/
}
4 replies
CC#
Created by _moare on 11/3/2022 in #help
Use dll from project reference
I have a class library which adds a few helper functions to a nuget package. This nuget package requires the System.Windows.Forms.dll. My main project references the class library and my class library references the nuget package. When i add the DLL to the main project and reference it from there everything works as expected. But when i add it to my class library, it cant be found when running. Could not load file or assembly 'System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. Das System kann die angegebene Datei nicht finden. Is there a way to make this work? Project: .net core 6
7 replies