Skip to content

Commit

Permalink
Add Windows Debug Project
Browse files Browse the repository at this point in the history
  • Loading branch information
TheR00st3r committed Nov 13, 2023
1 parent fe6b5db commit f9b5232
Show file tree
Hide file tree
Showing 9 changed files with 136 additions and 11 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -369,4 +369,5 @@ FodyWeavers.xsd
Docs/build
.env
cs2
counterstrikesharp.zip
counterstrikesharp.zip
localnotes.md
23 changes: 18 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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

Expand All @@ -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/
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions PugSharp.DebugDummy/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");
20 changes: 20 additions & 0 deletions PugSharp.DebugDummy/PugSharp.DebugDummy.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<PropertyGroup Condition="Exists('..\cs2\game\csgo\addons\counterstrikesharp\plugins')">
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<OutputPath>..\cs2\game\csgo\addons\counterstrikesharp\plugins\PugSharp\</OutputPath>
</PropertyGroup>


<ItemGroup>
<ProjectReference Include="..\PugSharp\PugSharp.csproj" />
</ItemGroup>

</Project>
8 changes: 7 additions & 1 deletion PugSharp.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
11 changes: 7 additions & 4 deletions PugSharp/PugSharp.csproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>

<PackageReference Include="CounterStrikeSharp.API" Version="1.0.30" />

<PackageReference Include="CounterStrikeSharp.API" Version="1.0.50" >
<PrivateAssets>none</PrivateAssets>
<ExcludeAssets>runtime</ExcludeAssets>
</PackageReference>

<PackageReference Include="OneOf" Version="3.0.263" />
</ItemGroup>
Expand Down
2 changes: 2 additions & 0 deletions Test/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");
14 changes: 14 additions & 0 deletions Test/Test.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\PugSharp\PugSharp.csproj" />
</ItemGroup>

</Project>
64 changes: 64 additions & 0 deletions install-windows.ps1
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit f9b5232

Please sign in to comment.