【发布时间】:2014-04-24 07:11:02
【问题描述】:
我的WPF 应用程序使用ClickOnce 部署。
在Visual Studio 我打开“Project properties / Publish”。
我有:
- 发布位置
- 发布网址
- 版本
- 签名
问题是,我必须发布每个版本以进行测试和生产。
它们之间的区别在于属性publish location 和publish URL。目前我必须执行两次该过程,同时在发布生产之前更改值。
所以按下发布的结果是一个包含文件夹“ApplicationFiles”的文件夹、application manifest 文件和一个setup.exe。
然后我决定使用 NANT 自动化这个过程。
我首先构建/发布应用程序进行测试(这里我设置 .csproj 文件位置、发布文件夹和应用程序变量)
<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>
有了这个,我发现 build 没有设置发布者。另外,我需要更改提供程序 URL,因为该应用程序也是通过 Internet 安装的(用于测试和生产的 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 文件中获取值。
考虑到以上所有问题,我有三个问题:
1.
有没有办法使用正确的参数构建应用程序,所以 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>
【问题讨论】:
-
在构建之前调用控制台应用程序并为构建本身使用控制台应用程序对您来说是一种可能的解决方案吗?还是必须是 NANT?
标签: visual-studio-2010 msbuild clickonce nant mage