나는 계속해서 Mage에 대한 언급을 보았지만, 그것이 무엇이고 왜 유용하고 인기가 있는지는 구체적으로 이해하지 못한다. 만약 누군가가 그 일의 빠른 요약을 줄 수 있다면, 대단히 감사 할 것입니다!Mage 란 무엇이며 어떤 점에서 유용합니까?
덕분에 ~
나는 계속해서 Mage에 대한 언급을 보았지만, 그것이 무엇이고 왜 유용하고 인기가 있는지는 구체적으로 이해하지 못한다. 만약 누군가가 그 일의 빠른 요약을 줄 수 있다면, 대단히 감사 할 것입니다!Mage 란 무엇이며 어떤 점에서 유용합니까?
덕분에 ~
Mage.exe는 .NET Framework 응용 프로그램에 대한 매니페스트 생성하고 편집 명령 행 도구. UI 버전도 있습니다. MageUI.exe
일반적으로 수동으로 ClickOnce deployment manifests을 사용합니다.
이
미치 밀은 훌륭한 대답을했다 서명 된 ClickOnce 응용 프로그램에 사용되는, 방금 마법사로 밖으로 시작하는 경우, 그가주는 마지막 링크를 읽어!
저는 다른 사람들이 ClickOnce 프로젝트에 도움을주기 위해 몇 가지 실제 코드를 공유하고 싶습니다. 나는 MSBUILD from the command-line to "create" the deployment을 사용하는 것이 자동화 된 빌드 프로세스에 완벽하다는 것을 발견했다. I 절대 Visual Studio에서 게시 마법사를 실행하십시오. 하지만 VS에서 게시 탭의 모든 정보를 지정하므로 명령 줄에서이를 수행 할 필요가 없습니다. 예를 들어, "응용 프로그램 파일"은 명령 줄에서 수행하는 방법을 모르는 것입니다. 응용 프로그램이 성공적으로 서버에 배포 한 후
이 THEN ... 내가 한 서버에서 다른 서버 ClickOnce 배포 내 마이그레이션의 일환으로 "마법사"를 사용 (예 : 시험 -> Staging-> 생산)당신이 "TESTSERVER"에서 "QAServer"또는 "준비"또는 "생산에서 ClickOnce를 응용 프로그램을 마이그레이션 할 때, 나중에 그런
&"$Env:windir\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe" "C:\Projects\MyCoolApp.sln" /t:clean /t:publish /p:Configuration=Release /p:ApplicationRevision=$Env:CCNETLABEL /p:PublishDir="\\TestServer\MyCoolAppFolder/" /p:PublishUrl="\\TestServer\MyCoolAppFolder/"
예를 들어 (A PowerShell 스크립트는 CruiseControl을 작업에서 실행하는 솔루션을 구축하는) "... 그렇게하려면 복잡한 스크립트를 작성해야합니다. 다음은 내가 생각해 낸 것입니다 :
#########################################################################################
# PowerShell Script to Migrate a ClickOnce Deployment from one server to another.
# This is my first attempt at PowerShell... pardon the bad or incorrect code. :-)
# To run a PowerShell script from CruiseControl.Net:
# http://www.cruisecontrolnet.org/projects/ccnet/wiki/PowerShell_Task
# NOTE: When doing the initial build, ensure that the ProviderURL and ProviderDir are set.
#########################################################################################
$SourceDir = "\\TestServer\MyCoolAppFolder"
$DestDir = "\\StagingServer\MyCoolAppFolder"
$DeploymentManifestName = "MyCoolApp.application"
$DeploymentDestUrl = "file://StagingServer/MyCoolAppFolder"
# If your application is one that connects to a database, then likely you want it to point
# to a different database depending what environment it's been deployed to.
# I use a SQL Server connection for this example.
$ConnStringName = "MyCoolAppConnectionString"
$ConnStringValue = "data source=StagingServerInstance;Initial Catalog=MyCoolAppDB;persist security info=True;user id=Gregg;password=Gregg"
# Unfortunately, you *must* specify the publisher when doing Mage, even though you specified it
# when you did the original publish, otherwise Mage will change the Publisher value to the
# name of your Application. A bug in Mage I suspect.
$Publisher = "Gregg Cleland"
# Risk: This next line assumes that the pfx certificate file is readily available.
# Just be certain it's the same key you used when you published originally.
$AuthenticationKeyPath = "C:\Projects\MyCoolApp\MyCoolApp_TemporaryKey.pfx"
# Note: This references the .NET 3.5 version of mage... the .NET 4.0 version of mage.exe can be found at:
# C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools\mage.exe
$MAGE = "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\mage.exe"
#########################################################################################
# Start off at the source location.
Set-Location $SourceDir
#########################################################################################
# Get the application manifest directory name and application manifest file name.
[xml]$doc = Get-Content $DeploymentManifestName
$ns = New-Object Xml.XmlNamespaceManager $doc.NameTable
$ns.AddNamespace("asmv1", "urn:schemas-microsoft-com:asm.v1")
$ns.AddNamespace("asmv2", "urn:schemas-microsoft-com:asm.v2")
$xpath = "/asmv1:assembly/asmv2:dependency/asmv2:dependentAssembly"
$appManifestPath = $doc.SelectSingleNode($xpath, $ns).codebase # Example: = "Application Files\MyCoolApp_1_0_0_5\MyApp.exe.manifest"
$position = $appManifestPath.LastIndexOf('\');
$appManifestDir = $appManifestPath.SubString(0, $position); # Example: "Application Files\MyCoolApp_1_0_0_5"
$appManifestFile = $appManifestPath.SubString($position + 1); # Example: "MyCoolApp.exe.manifest"
#########################################################################################
# Copy the deployment files and the latest application files to destination.
# Note: Do not forget to ensure the CruiseControl Service Logon has permissions to write to destination!
# Todo: If robocopy fails, throw "robocopy failed!" Most likely it is an Error 5, Access Denied
# b/c the CruiseControl Service logon account doesn't have permission to copy to create/write to destination.
$CurrentDir = "$DestDir\$appManifestDir"
robocopy "$SourceDir" "$DestDir" /XO
robocopy "$SourceDir\$appManifestDir" $CurrentDir /MIR /XO
#########################################################################################
# Now that we have copied the latest build, let us navigate down into the destination's
# application manifest directory and do some work.
Set-Location $CurrentDir
#########################################################################################
# Remove the .deploy extension from all files. (Mage will throw an exception if you don't do this)
Get-ChildItem -Include *.deploy -Recurse | Rename-Item -NewName { [System.IO.Path]::ChangeExtension($_.Name, "") }
#########################################################################################
# Modify the XML in the app.config file per your needs (e.g. change the connectionStrings)
[xml]$doc = Get-Content $AppConfigFileName
$node = $doc.SelectSingleNode("configuration/connectionStrings/add[@name='$ConnStringName']")
$node.connectionString = $ConnStringValue
$xmldocPath = $PWD.ProviderPath # hack to avoid getting the silly namespace prefixed to the path for UNC paths
$doc.Save("$xmldocPath\$AppConfigFileName") # For some reason, seems to require the fully qualified path
#########################################################################################
# Finally... We get to the part where we use MAGE!
# Use MAGE to update the application manifest hash and sign it.
&"$MAGE" -Update $appManifestFile -FromDirectory "$CurrentDir" -CertFile $AuthenticationKeyPath
#########################################################################################
# Re-Add the ".deploy" extension to all files EXCEPT those that end in "application" or
# "manifest". Do this AFTER signing.
Get-ChildItem -Recurse | Where-Object { !$_.PSIsContainer -and !$_.Name.EndsWith(".application") -and !$_.Name.EndsWith(".manifest") } | Rename-Item -NewName { $_.Name + ".deploy" }
#########################################################################################
# Finally, go back up to the Deployment folder and update the deployment manifest
Set-Location "..\..\"
&"$MAGE" -Update $DeploymentManifestName -ProviderUrl "$DeploymentDestUrl/$DeploymentManifestName" -AppManifest "$appManifestPath" -Publisher $Publisher -CertFile $AuthenticationKeyPath
PowerShell 스크립트가 훌륭합니다! 그 점에 대해 정말 고마워. –