2014-04-24 45 views
0

我的WPF应用程序部署为ClickOnce使用NANT脚本发布ClickOnce应用程序

Visual Studio我打开“Project properties/Publish”。

在那里,我有:

  • 发布位置
  • 发布URL
  • 版本
  • 签名

的问题是,我必须公布每个版本的测试和生产。 它们之间的区别是属性publish locationpublish 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=&quot;${publisherName}&quot;" /> 
    </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="&quot;${testPublishUrl}&quot;" /> 
    <arg value="-Publisher" /> 
    <arg value="&quot;${publisherName}&quot;" /> 
    </exec> 
    <echo message="Updated" /> 
</target> 

有了这个,我已经更新了application manifest文件用正确的值(PublisherProviderUrl)...

我做同样的生产版本,这意味着我构建应用程序到另一个文件夹并与不同的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> 
+0

在构建和使用控制台应用程序构建本身之前调用控制台应用程序对您来说可能是一个可行的解决方案吗?或者它是南特? – Herdo

回答

0

我能而无需显式登录创建正确生成,你在你的问题(SETUP.EXE,应用程序文件夹等)中提到的资产任务表现。

的“clean_and_publish_application”任务执行以下操作

  1. 清洁项目
  2. 重建项目
  3. 发布项目**在这里,我提供几个参数,指定我发布的网址,BootstrapperSDKPath,应用程序版本,和应用修订版

    <target name="clean_and_publish_application" description="Build the application."> 
    <echo message="Clean the build directory"/> 
    <msbuild project ="${src.dir}\${target.assembly.name}.csproj"> 
         <arg value="/property:Configuration=Debug;outdir=bin\Debug" /> 
         <arg value="/t:clean" /> 
    </msbuild> 
    <echo message="Rebuild the application"/> 
    <msbuild project ="${src.dir}\${target.assembly.name}.csproj"> 
    <arg value="/property:Configuration=Debug;outdir=bin\Debug" /> 
    <arg value="/t:rebuild" /> 
    </msbuild> 
    <echo message="Publish the application"/> 
    <msbuild project ="${src.dir}\${target.assembly.name}.csproj"> 
    <arg value="/p:publishurl=${publish.url}; 
    GenerateBootstrapperSdkPath= 
    C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\Bootstrapper\; 
    ApplicationVersion=${app.version}; 
    ApplicationRevision=${app.revision}" /> 
    <arg value="/t:publish" /> 
    </msbuild> 
    </target> 
    

创建setup.exe文件需要BootstrapperSdkPath属性。我硬编码的位置,因为它不会改变。 MSBuild正在该目录中查找setup.bin文件。

的ApplicationVersion财产被格式化,例如2.0.0。%2A

的ApplicationRevision属性被格式化为一个数,例如24(这些值是在发布版本中,我们在Visual Studio中看到的。我从来没有真正更新AssemplyInfo.cs文件。)

您看到.csproj文件中列出的任何属性都可以作为msbuild的参数传递。我发现这个文档非常有帮助MSBuild Command-Line Reference

上述任务完成您所需要的一切除了实际上将文件复制到您的发布网址(仍然在寻找这个答案)。于是我就手动所有的文件在app.config目录复制发布创建

<target name="copy_src"> 
<echo message="Copying app.config folder"/> 
    <copy todir="${publish.url}" overwrite="true" failonerror="true"> 
     <fileset basedir="${src.dir}\${app.config.location}"> 
      <include name="**" /> 
     </fileset> 
    </copy> 
</target> 

我跑在队伍城市这些脚本。因为我使用了发布目标,所以我不必担心签署任何清单。此外,我使用NAnt.Contrib.Tasks.dll中的msbuild任务,您可以在这里下载NAntContrib

相关问题