From f9b5232c69e1fe8d81335156eab1b6df0e1c43e1 Mon Sep 17 00:00:00 2001 From: TheR00st3r Date: Mon, 13 Nov 2023 20:40:42 +0100 Subject: [PATCH] Add Windows Debug Project --- .gitignore | 3 +- Makefile | 23 +++++-- PugSharp.DebugDummy/Program.cs | 2 + .../PugSharp.DebugDummy.csproj | 20 ++++++ PugSharp.sln | 8 ++- PugSharp/PugSharp.csproj | 11 ++-- Test/Program.cs | 2 + Test/Test.csproj | 14 ++++ install-windows.ps1 | 64 +++++++++++++++++++ 9 files changed, 136 insertions(+), 11 deletions(-) create mode 100644 PugSharp.DebugDummy/Program.cs create mode 100644 PugSharp.DebugDummy/PugSharp.DebugDummy.csproj create mode 100644 Test/Program.cs create mode 100644 Test/Test.csproj create mode 100644 install-windows.ps1 diff --git a/.gitignore b/.gitignore index f521886a..35a7a047 100644 --- a/.gitignore +++ b/.gitignore @@ -369,4 +369,5 @@ FodyWeavers.xsd Docs/build .env cs2 -counterstrikesharp.zip \ No newline at end of file +counterstrikesharp.zip +localnotes.md diff --git a/Makefile b/Makefile index 67fcb5ec..3f818b6c 100644 --- a/Makefile +++ b/Makefile @@ -5,9 +5,9 @@ .SILENT: init-env fix-metamod - ## Variables currentDir = $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) +currentDirWin = $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) userId = $(shell id -u) groupId = $(shell id -g) user = $(userId):$(groupId) @@ -29,6 +29,7 @@ build-and-copy: git-pull build-debug copy-pugsharp build-and-copy-docker: git-pull build-debug-docker copy-pugsharp init-all: prepare-folders init-env install-deps pull-csserver start-csserver attach-csserver init-all-docker: prepare-folders init-env install-deps-docker pull-csserver start-csserver attach-csserver +install-all-windows: install-windows-steamcmd install-windows install-deps: install-counterstrikesharp install-metamod install-deps-docker: install-counterstrikesharp-docker install-metamod clean-all: clean-csserver clean-env clean-build @@ -41,11 +42,11 @@ prepare-folders: mkdir -p $(currentDir)/cs2 && chmod 777 $(currentDir)/cs2 init-env: - cp $(currentDir)/.env.example $(currentDir)/.env ; + cp $(currentDir)/.env.example $(currentDir)/.env ; install-counterstrikesharp: mkdir -p $(currentDir)/cs2/game/csgo/addons/ - wget -q -O $(currentDir)/counterstrikesharp.zip $(shell curl -s -L -H "Accept: application/vnd.github+json" https://api.github.com/repos/roflmuffin/CounterStrikeSharp/releases/tags/$(shell dotnet list PugSharp/PugSharp.csproj package --format json | jq -r '.projects[].frameworks[].topLevelPackages[] | select(.id == "CounterStrikeSharp.API") | .resolvedVersion' | sed 's|1.0.|v|g') | jq -r '.assets[] | select(.browser_download_url | test("with-runtime")) | .browser_download_url') + wget -q -O $(currentDir)/counterstrikesharp.zip $(shell curl -s -L -H "Accept: application/vnd.github+json" https://api.github.com/repos/roflmuffin/CounterStrikeSharp/releases/tags/$(shell dotnet list PugSharp/PugSharp.csproj package --format json | jq -r '.projects[].frameworks[].topLevelPackages[] | select(.id == "CounterStrikeSharp.API") | .resolvedVersion' | sed 's|1.0.|v|g') | jq -r '.assets[] | select(.browser_download_url | test("with-runtime")) | .browser_download_url') unzip -o $(currentDir)/counterstrikesharp.zip -d $(currentDir)/cs2/game/csgo rm -rf $(currentDir)/counterstrikesharp.zip @@ -58,7 +59,7 @@ install-counterstrikesharp-docker: wget -q -O /app/counterstrikesharp.zip $(shell curl -s -L -H "Accept: application/vnd.github+json" https://api.github.com/repos/roflmuffin/CounterStrikeSharp/releases/tags/$(shell dotnet list PugSharp/PugSharp.csproj package --format json | jq -r '.projects[].frameworks[].topLevelPackages[] | select(.id == "CounterStrikeSharp.API") | .resolvedVersion' | sed 's|1.0.|v|g') | jq -r '.assets.[] | select(.browser_download_url | test("with-runtime")) | .browser_download_url'); \ unzip -o /app/counterstrikesharp.zip -d /app/cs2/game/csgo; \ rm -rf /app/counterstrikesharp.zip; \ - chown -R $(user) /app/cs2/game/csgo/addons;" + chown -R $(user) /app/cs2/game/csgo/addons;" install-metamod: mkdir -p $(currentDir)/cs2/game/csgo/ @@ -67,10 +68,22 @@ install-metamod: fix-metamod: ./resources/acmrs.sh - + install-jq-and-unzip: apt-get update && apt-get install jq unzip -y +# install-windows: +# powershell Start-Process -NoNewWindow -WorkingDirectory ${CURDIR} -FilePath "$$env:LOCALAPPDATA\Microsoft\WinGet\Links\steamcmd" -ArgumentList '+force_install_dir ${CURDIR}\cs2\ +login Anonymous +app_update 730 validate +exit'; + +# install-windows-steamcmd: +# winget install --id Valve.SteamCMD --exact --accept-source-agreements --disable-interactivity --accept-source-agreements --force + +# install-metamod-windows: +# mkdir -p ${CURDIR}/cs2/game/csgo/ +# export LATESTMM=$(shell wget -qO- https://mms.alliedmods.net/mmsdrop/2.0/mmsource-latest-windows); \ +# powershell Start-Process wget -Argume -qO- https://mms.alliedmods.net/mmsdrop/2.0/$$LATESTMM | tar xvzf - -C ${CURDIR}/cs2/game/csgo + + ## base commands pull-csserver: docker pull joedwards32/cs2 diff --git a/PugSharp.DebugDummy/Program.cs b/PugSharp.DebugDummy/Program.cs new file mode 100644 index 00000000..3751555c --- /dev/null +++ b/PugSharp.DebugDummy/Program.cs @@ -0,0 +1,2 @@ +// See https://aka.ms/new-console-template for more information +Console.WriteLine("Hello, World!"); diff --git a/PugSharp.DebugDummy/PugSharp.DebugDummy.csproj b/PugSharp.DebugDummy/PugSharp.DebugDummy.csproj new file mode 100644 index 00000000..586d215b --- /dev/null +++ b/PugSharp.DebugDummy/PugSharp.DebugDummy.csproj @@ -0,0 +1,20 @@ + + + + Exe + net7.0 + enable + enable + + + + false + ..\cs2\game\csgo\addons\counterstrikesharp\plugins\PugSharp\ + + + + + + + + diff --git a/PugSharp.sln b/PugSharp.sln index c29c4a39..41e96051 100644 --- a/PugSharp.sln +++ b/PugSharp.sln @@ -31,7 +31,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PugSharp.Api.Contract", "Pu EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PugSharp.Server.Contract", "PugSharp.Server.Contract\PugSharp.Server.Contract.csproj", "{20179A63-B86A-436A-9D8D-93B17EDEE6F9}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PugSharp.Api.Json", "PugSharp.Api.Json\PugSharp.Api.Json.csproj", "{85B467F1-65B1-4332-8935-1AC5FFFD927E}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PugSharp.Api.Json", "PugSharp.Api.Json\PugSharp.Api.Json.csproj", "{85B467F1-65B1-4332-8935-1AC5FFFD927E}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PugSharp.DebugDummy", "PugSharp.DebugDummy\PugSharp.DebugDummy.csproj", "{572B6279-3307-4D11-A834-1D598CA2C21C}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -83,6 +85,10 @@ Global {85B467F1-65B1-4332-8935-1AC5FFFD927E}.Debug|Any CPU.Build.0 = Debug|Any CPU {85B467F1-65B1-4332-8935-1AC5FFFD927E}.Release|Any CPU.ActiveCfg = Release|Any CPU {85B467F1-65B1-4332-8935-1AC5FFFD927E}.Release|Any CPU.Build.0 = Release|Any CPU + {572B6279-3307-4D11-A834-1D598CA2C21C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {572B6279-3307-4D11-A834-1D598CA2C21C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {572B6279-3307-4D11-A834-1D598CA2C21C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {572B6279-3307-4D11-A834-1D598CA2C21C}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/PugSharp/PugSharp.csproj b/PugSharp/PugSharp.csproj index 7b609ae5..e23aec2a 100644 --- a/PugSharp/PugSharp.csproj +++ b/PugSharp/PugSharp.csproj @@ -1,14 +1,17 @@ - + net7.0 enable enable - + - - + + + none + runtime + diff --git a/Test/Program.cs b/Test/Program.cs new file mode 100644 index 00000000..3751555c --- /dev/null +++ b/Test/Program.cs @@ -0,0 +1,2 @@ +// See https://aka.ms/new-console-template for more information +Console.WriteLine("Hello, World!"); diff --git a/Test/Test.csproj b/Test/Test.csproj new file mode 100644 index 00000000..f4c2a9a4 --- /dev/null +++ b/Test/Test.csproj @@ -0,0 +1,14 @@ + + + + Exe + net7.0 + enable + enable + + + + + + + diff --git a/install-windows.ps1 b/install-windows.ps1 new file mode 100644 index 00000000..ca9aadc0 --- /dev/null +++ b/install-windows.ps1 @@ -0,0 +1,64 @@ +$TARGET_DIR = "cs2\game\csgo" +$GAMEINFO_FILE = "$TARGET_DIR\gameinfo.gi" + +Write-Output "Install SteamCMD" +winget install --id Valve.SteamCMD --exact --accept-source-agreements --disable-interactivity --accept-source-agreements --force + +Write-Output "Create csgo folder" +New-Item -ItemType Directory -Force -Path $TARGET_DIR + +Write-Output "Install CS2" +Start-Process -NoNewWindow -FilePath "$env:LOCALAPPDATA\Microsoft\WinGet\Links\steamcmd" -ArgumentList "+force_install_dir $PSScriptRoot\cs2\ +login Anonymous +app_update 730" +# Start-Process -NoNewWindow -FilePath "$env:LOCALAPPDATA\Microsoft\WinGet\Links\steamcmd" -ArgumentList "+force_install_dir $PSScriptRoot\cs2\ +login Anonymous +app_update 730 validate +exit" + +Write-Output "Installed CS2" +Write-Output "Installed CS2" +Write-Output "Installed CS2" +Write-Output "Installed CS2" +Write-Output "Installed CS2" +Write-Output "Installed CS2" +Write-Output "Installed CS2" +Write-Output "Installed CS2" +Write-Output "Installed CS2" +Write-Output "Installed CS2" +Write-Output "Installed CS2" +Write-Output "Installed CS2" +Write-Output "Installed CS2" + +Write-Output "Load MetaModVersion" +$latestMM = Invoke-RestMethod "https://mms.alliedmods.net/mmsdrop/2.0/mmsource-latest-windows" + +Write-Output "Download MetaMod Version $latestMM" +Invoke-WebRequest "https://mms.alliedmods.net/mmsdrop/2.0/$latestMM" -OutFile "$TARGET_DIR\latestMM.zip" + +Write-Output "Extract MetaMod Version $latestMM" +Expand-Archive "$TARGET_DIR\latestMM.zip" -DestinationPath $TARGET_DIR -Force + +Write-Output "Fix GameInfo" +if (Test-Path $GAMEINFO_FILE) { + $NEW_ENTRY = " Game csgo/addons/metamod" + $SEL = Select-String -Path $GAMEINFO_FILE -Pattern $NEW_ENTRY + if ($SEL -ne $null) { + Write-Output "The entry '$NEW_ENTRY' already exists in $GAMEINFO_FILE. No changes were made." + } + else { + (Get-Content $GAMEINFO_FILE) | + Foreach-Object { + $_ # send the current line to output + if ($_ -match "Game_LowViolence") { + #Add Lines after the selected pattern + $NEW_ENTRY + } + } | Set-Content $GAMEINFO_FILE + + Write-Output "The file $GAMEINFO_FILE has been modified successfully. '$NEW_ENTRY' has been added." + } +} + +Write-Output "Install CounterStrikeSharp" + +# TODO Install CSS +# wget -q -O $(currentDir)/counterstrikesharp.zip $(shell curl -s -L -H "Accept: application/vnd.github+json" https://api.github.com/repos/roflmuffin/CounterStrikeSharp/releases/tags/$(shell dotnet list PugSharp/PugSharp.csproj package --format json | jq -r '.projects[].frameworks[].topLevelPackages[] | select(.id == "CounterStrikeSharp.API") | .resolvedVersion' | sed 's|1.0.|v|g') | jq -r '.assets[] | select(.browser_download_url | test("with-runtime")) | .browser_download_url') + + +Write-Output "Successfully prepared CS. To start: .\cs2\game\bin\win64\cs2.exe -dedicated +map de_dust2" \ No newline at end of file