첨부 소스 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170

■ MSBuild와 Advanced Installer를 사용해 설치 파일 만들기 예제

 

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"

 

728x90

 

■ MSBuild와 Advanced Installer를 사용해 설치 파일 만들기

 

▶ build.ps1

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)
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요