Use MSBuild to improve make.ps1's clean function
This commit is contained in:
66
make.ps1
66
make.ps1
@@ -1,3 +1,23 @@
|
|||||||
|
function FindMSBuild
|
||||||
|
{
|
||||||
|
$msBuildVersions = @("4.0")
|
||||||
|
foreach ($msBuildVersion in $msBuildVersions)
|
||||||
|
{
|
||||||
|
$key = "HKLM:\SOFTWARE\Microsoft\MSBuild\ToolsVersions\{0}" -f $msBuildVersion
|
||||||
|
$property = Get-ItemProperty $key -ErrorAction SilentlyContinue
|
||||||
|
if ($property -eq $null -or $property.MSBuildToolsPath -eq $null)
|
||||||
|
{
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
$path = Join-Path $property.MSBuildToolsPath -ChildPath "MSBuild.exe"
|
||||||
|
if (Test-Path $path)
|
||||||
|
{
|
||||||
|
return $path
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $null
|
||||||
|
}
|
||||||
|
|
||||||
if ($args.Length -eq 0)
|
if ($args.Length -eq 0)
|
||||||
{
|
{
|
||||||
echo "Command list:"
|
echo "Command list:"
|
||||||
@@ -19,22 +39,14 @@ else
|
|||||||
|
|
||||||
if ($command -eq "all")
|
if ($command -eq "all")
|
||||||
{
|
{
|
||||||
$msBuildVersions = @("4.0")
|
$msBuild = FindMSBuild
|
||||||
foreach ($msBuildVersion in $msBuildVersions)
|
if ($msBuild -eq $null)
|
||||||
{
|
{
|
||||||
$key = "HKLM:\SOFTWARE\Microsoft\MSBuild\ToolsVersions\{0}" -f $msBuildVersion
|
echo "Unable to locate an appropriate version of MSBuild."
|
||||||
$property = Get-ItemProperty $key -ErrorAction SilentlyContinue
|
}
|
||||||
if ($property -eq $null -or $property.MSBuildToolsPath -eq $null)
|
else
|
||||||
{
|
{
|
||||||
continue
|
$proc = Start-Process $msBuild /t:Rebuild -NoNewWindow -PassThru -Wait
|
||||||
}
|
|
||||||
$path = Join-Path $property.MSBuildToolsPath -ChildPath "MSBuild.exe"
|
|
||||||
if (-not (Test-Path $path))
|
|
||||||
{
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
$proc = Start-Process $path /t:Rebuild -NoNewWindow -PassThru -Wait
|
|
||||||
$proc.WaitForExit()
|
|
||||||
if ($proc.ExitCode -ne 0)
|
if ($proc.ExitCode -ne 0)
|
||||||
{
|
{
|
||||||
echo "Build failed. If just the development tools failed to build, try installing Visual Studio. You may also still be able to run the game."
|
echo "Build failed. If just the development tools failed to build, try installing Visual Studio. You may also still be able to run the game."
|
||||||
@@ -43,21 +55,23 @@ if ($command -eq "all")
|
|||||||
{
|
{
|
||||||
echo "Build succeeded."
|
echo "Build succeeded."
|
||||||
}
|
}
|
||||||
break
|
|
||||||
}
|
|
||||||
if ($proc -eq $null)
|
|
||||||
{
|
|
||||||
echo "Unable to locate an appropriate version of MSBuild."
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif ($command -eq "clean")
|
elseif ($command -eq "clean")
|
||||||
{
|
{
|
||||||
rm *.pdb
|
$msBuild = FindMSBuild
|
||||||
rm *.config
|
if ($msBuild -eq $null)
|
||||||
rm *.exe
|
{
|
||||||
rm *.dll
|
echo "Unable to locate an appropriate version of MSBuild."
|
||||||
rm mods/*/*.dll
|
}
|
||||||
echo "Clean complete."
|
else
|
||||||
|
{
|
||||||
|
$proc = Start-Process $msBuild /t:Clean -NoNewWindow -PassThru -Wait
|
||||||
|
rm *.dll # delete third party dependencies
|
||||||
|
rm *.config
|
||||||
|
rm mods/*/*.dll
|
||||||
|
echo "Clean complete."
|
||||||
|
}
|
||||||
}
|
}
|
||||||
elseif ($command -eq "version")
|
elseif ($command -eq "version")
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user