■ MSBuild와 Advanced Installer를 사용해 설치 파일을 만드는 방법을 보여준다.
▶ MSBuild와 Advanced Installer를 사용해 설치 파일 만들기 예제
1 2 3 4 5 6 7 8 9 |
d:\script\build.ps1 ` -CSharpProjectFilePath "D:\LAKE\LAKE.HOST\LAKE.HOST.csproj" ` -CSharpCustomActionProjectFilePath "D:\LAKE\LAKE.SETUP.ACTION\LAKE.SETUP.ACTION.csproj" ` -SourceBinaryDirectoryPath "D:\LAKE\BINARY\RELEASE" ` -AdvancedInstallerProjectFilePath "D:\LAKE\SETUP\LAKE.aip" ` -PackageVersion "1.0.0" ` -TargetBinaryDirectoryPath "D:\LAKE\SETUP\Setup Files" |
▶ MSBuild와 Advanced Installer를 사용해 설치 파일 만들기 : build.ps1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
Param ( [string]$CSharpProjectFilePath, [string]$CSharpCustomActionProjectFilePath, [string]$SourceBinaryDirectoryPath, [string]$AdvancedInstallerProjectFilePath, [string]$PackageVersion, [string]$TargetBinaryDirectoryPath ) #################################################################################################### BEGIN EXAMINE SCRIPT PARAMETERS Write-Host 'BEGIN SCRIPT' if([string]::IsNullOrWhiteSpace($CSharpProjectFilePath)) { throw 'C# PROJECT FILE PATH IS NULL OR WHITE SPACE' } if(-not(Test-Path $CSharpProjectFilePath)) { throw 'C# PROJECT FILE DOES NOT EXIST' } if(-not([string]::IsNullOrWhiteSpace($CSharpCustomActionProjectFilePath))) { if(-not(Test-Path $CSharpCustomActionProjectFilePath)) { throw 'C# CUSTOM ACTION PROJECT FILE DOES NOT EXIST' } } if([string]::IsNullOrWhiteSpace($SourceBinaryDirectoryPath)) { throw 'SOURCE BINARY DIRECTORY PATH IS NULL OR WHITE SPACE' } if(-not(Test-Path $SourceBinaryDirectoryPath)) { throw 'SOURCE BINARY DIRECTORY PATH DOES NOT EXIST' } if([string]::IsNullOrWhiteSpace($AdvancedInstallerProjectFilePath)) { throw 'ADVANCED INSTALLER PROJECT FILE PATH IS NULL OR WHITE SPACE' } if(-not(Test-Path $AdvancedInstallerProjectFilePath)) { throw 'ADVANCED INSTALLER PROJECT FILE DOES NOT EXIST' } if([string]::IsNullOrWhiteSpace($TargetBinaryDirectoryPath)) { throw 'TARGET BINARY DIRECTORY PATH IS NULL OR WHITE SPACE' } if(-not(Test-Path $TargetBinaryDirectoryPath)) { throw 'TARGET BINARY DIRECTORY PATH DOES NOT EXIST' } Write-Host "C# PROJECT FILE PATH : $CSharpProjectFilePath" Write-Host "C# CUSTOM ACTION PROJECT FILE PATH : $CSharpCustomActionProjectFilePath" Write-Host "SOURCE BINARY DIRECTORY PATH : $SourceBinaryDirectoryPath" Write-Host "ADVANCED INSTALLER PROJECT FILE PATH : $AdvancedInstallerProjectFilePath" Write-Host "SETUP PACKAGE VERSION : $PackageVersion" Write-Host "TARGET BINARY DIRECTORY PATH : $TargetBinaryDirectoryPath" #################################################################################################### END EXAMINE SCRIPT PARAMETERS try { #################################################################################################### BEGIN DELETE FILES Start-Process -FilePath "MSBuild" -ArgumentList "$CSharpProjectFilePath -t:Clean -p:Configuration=Release" -Wait if(-not([string]::IsNullOrWhiteSpace($CSharpCustomActionProjectFilePath))) { Start-Process -FilePath "MSBuild" -ArgumentList "$CSharpCustomActionProjectFilePath -t:Clean -p:Configuration=Release" -Wait } Start-Process -FilePath "cmd" -ArgumentList "/c rmdir /s /q $TargetBinaryDirectoryPath" -Wait #################################################################################################### END DELETE FILES #################################################################################################### BEGIN BUILD PROJECT Start-Process -FilePath "MSBuild" -ArgumentList "$CSharpProjectFilePath -t:Rebuild -p:Configuration=Release" -Wait if(-not([string]::IsNullOrWhiteSpace($CSharpCustomActionProjectFilePath))) { Start-Process -FilePath "MSBuild" -AgrumentList "$CSharpCustomActionProjectFilePath -t:Rebuild -p:Configuration=Release" -Wait } #################################################################################################### END BUILD PROJECT #################################################################################################### BEGIN COPY BINARY FILES Start-Process -FilePath "cmd" -ArgumentList "/c mkdir $TargetBinaryDirectoryPath" -Wait Start-Process -FilePath "cmd" -ArgumentList "/c xcopy $SourceBinaryDirectoryPath $TargetBinaryDirectoryPath /e /h /k" -Wait #################################################################################################### END COPY BINARY FILES #################################################################################################### BEGIN CLEAN PROJECT Start-Process -FilePath "MSBuild" -ArgumentList "$CSharpProjectFilePath -t:Clean -p:Configuration=Release" -Wait if(-not([string]::IsNullOrWhiteSpace($CSharpCustomActionProjectFilePath))) { Start-Process -FilePath "MSBuild" -ArgumentList "$CSharpCustomActionProjectFilePath -t:Clean -p:Configuration=Release" -Wait } #################################################################################################### END CLEAN PROJECT #################################################################################################### BEGIN UPDATE PACKAGE VERSION if(![string]::IsNullOrEmpty($PackageVersion)) { $newGuid = New-Guid $guidString = $newGuid.ToString().ToUpper() Start-Process -FilePath "advinst.exe" -ArgumentList "/edit $AdvancedInstallerProjectFilePath /SetVersion $PackageVersion" -Wait Start-Process -FilePath "advinst.exe" -ArgumentList "/edit $AdvancedInstallerProjectFilePath /SetProductCode -langid 1033 -guid {$guidString}" -Wait } #################################################################################################### END UPDATE PACKAGE VERSION #################################################################################################### BEGIN BUILD PACKAGE Start-Process -FilePath "advinst.exe" -ArgumentList "/rebuild $AdvancedInstallerProjectFilePath" -Wait #################################################################################################### END BUILD PACKAGE } catch { Write-Output "# $_.Exception.ToString()" exit(1) } exit(0) |