我的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