我的WPF
應用程序部署爲ClickOnce
。使用NANT腳本發佈ClickOnce應用程序
在Visual Studio
我打開「Project properties/Publish
」。
在那裏,我有:
- 發佈位置
- 發佈URL
- 版本
- 簽名
的問題是,我必須公佈每個版本的測試和生產。 它們之間的區別是屬性publish location
和publish URL
。目前,我必須執行兩次流程,同時在發佈生產前更改這些值。
因此,按發佈的結果是包含文件夾「ApplicationFiles
」,application manifest
文件和setup.exe
的文件夾。
然後我決定使用NANT自動化這個過程。
我建立/首先發布的應用程序進行測試(這裏我設置的.csproj文件的位置,發佈文件夾和應用程序varsion)
<target name="BuildTestApplication" depends="Clean" description="Build">
<echo message="Building..." />
<exec program="${msbuildExe}" workingdir="." verbose="true">
<arg value="${projectFile}" />
<arg value="/target:Clean;Publish" />
<arg value="/p:PublishDir=${testPublishFolder}" />
<arg value="/p:ApplicationVersion=${version}" />
<arg value="/p:Publisher="${publisherName}"" />
</exec>
<echo message="Built" />
</target>
有了這個,我發現,構建不設置出版商。另外我需要更改提供商URL,因爲應用程序也是通過互聯網安裝的(不同的URL用於測試和製作)。所以我做:
<target name="UpdateTestApplication" depends="BuildTestApplication" description="Update">
<echo message="Updating..." />
<exec program="${mageExe}" workingdir="." verbose="true">
<arg value="-Update" />
<arg value="${testPublishFolder}/EdpClient.application" />
<arg value="-ProviderUrl" />
<arg value=""${testPublishUrl}"" />
<arg value="-Publisher" />
<arg value=""${publisherName}"" />
</exec>
<echo message="Updated" />
</target>
有了這個,我已經更新了application manifest
文件用正確的值(Publisher
和ProviderUrl
)...
我做同樣的生產版本,這意味着我構建應用程序到另一個文件夾並與不同的ProviderUrl
更新和添加Publisher
,因爲它必須包含在每個mage
更新...
現在的問題是setup.exe
文件。 Setup.exe
在構建時生成,它取自.csproj
文件中的值。
考慮到所有上述的我有三個問題:
是否有建設有正確的參數應用的一種方式,所以setup.exe
將包含正確的價值觀?
2. 另外,如何在構建之前更新程序集信息(參數版本)?當從VS
發佈我需要更新它「Probject properties/Application/Assembly Information
」
3。 我注意到,當從VS
發佈時,應用程序清單文件也在「Application Files
」文件夾中生成,而使用MSBUILD
發佈時不是。這是爲什麼?
預先感謝您和問候,NO9
編輯:
我解決了這一問題#2像這樣:
<!--UPDATE ASSEMBLY INFORMATION BEFORE BUILD-->
<target name="UpdateAssemblyInfo">
<asminfo output="${assemblyInfoFile}" language="CSharp">
<imports>
<import namespace="System" />
<import namespace="System.Reflection" />
<import namespace="System.Resources" />
<import namespace="System.Runtime.CompilerServices" />
<import namespace="System.Runtime.InteropServices" />
<import namespace="System.Windows" />
</imports>
<attributes>
<attribute type="AssemblyTitleAttribute" value="some value" />
<attribute type="AssemblyDescriptionAttribute" value="some value" />
<attribute type="AssemblyConfigurationAttribute" value="some value" />
<attribute type="AssemblyCompanyAttribute" value="some value" />
<attribute type="AssemblyProductAttribute" value="some value" />
<attribute type="AssemblyVersionAttribute" value="some value" />
<attribute type="AssemblyFileVersionAttribute" value="some value" />
<attribute type="AssemblyCopyrightAttribute" value="some value" />
<attribute type="AssemblyTrademarkAttribute" value="some value" />
<attribute type="AssemblyCultureAttribute" value="some value" />
<attribute type="CLSCompliantAttribute" value="boolean value" />
<attribute type="ComVisibleAttribute" value="boolean value" />
</attributes>
</asminfo>
<echo file="${assemblyInfoFile}" append="true">
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]
</echo>
<echo message="Updated" />
</target>
含義我構建之前覆蓋Assembly.info
文件並添加相關的值。
而且問題#3
像這樣:
<!--COPY APPLICATION MANIFEST TO APPLICATIONFILES FOLDER-->
<target name="CopyTestApplicationManifestToApplicationFilesFolder" depends="Dependency target name" description="Update">
<echo message="Copying..." />
<copy
file="source file"
tofile="target file" />
<echo message="Copied" />
</target>
在構建和使用控制檯應用程序構建本身之前調用控制檯應用程序對您來說可能是一個可行的解決方案嗎?或者它是南特? – Herdo