Skip to content

Instantly share code, notes, and snippets.

@NoTimeForHero
Created April 10, 2022 00:30
Show Gist options
  • Save NoTimeForHero/891a0d3221d3d0802fdc629421a35f24 to your computer and use it in GitHub Desktop.
Save NoTimeForHero/891a0d3221d3d0802fdc629421a35f24 to your computer and use it in GitHub Desktop.
Создание ZIP архива из проекта Visual Studio без лишнего мусора
$projectName = Get-ChildItem .\ -Filter "*.sln" | Select-Object -ExpandProperty Name
if (!$projectName) {
Write-Host "Not found any *.SLN files in current directory!"
Write-Host "Exit with error..."
exit
}
$projectName = [io.path]::GetFileNameWithoutExtension($projectName)
$targetZip = $projectName + ".zip"
$gitStatus = git status 2>&1
if (($gitStatus -is [System.Management.Automation.ErrorRecord]) -And
($gitStatus[0].CategoryInfo.TargetName -Match "fatal: not a git repository")
) {
Write-Host "GIT Not initialized!"
git init
}
if (Get-Item -Path $targetZip -ErrorAction Ignore) {
Remove-Item $targetZip
Write-Host ("Removed old zip: " + $targetZip)
}
# TODO: Добавить автоматическое скачивание .gitignore из https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
git add *
git commit -m "Auto-commit"
# TODO: Добавить возможность автосборки проекта в VisualStudio
git archive --format=zip --output $targetZip master
& "$env:ProgramFiles\WinRar\winrar.exe" a -afzip $targetZip bin\Release
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment