使用 nant 和 wix 创建 MSI

发布于 2024-09-07 14:11:37 字数 6203 浏览 5 评论 0原文

我正在尝试使用 NAnt 为我的项目创建一个安装程序。 这就是我的构建脚本,就像

<?xml version="1.0"?>
<project name="pleats" default="build-release" xmlns="http://nant.sf.net/release/0.85/nant.xsd">

<target name="build-release" depends="clean, make-builddir, build, release-properties, copy-to-release, build-installer" />
<property name="tools.dir" value="${path::get-full-path('tools')}" />  
<property name="src.dir" value="${path::get-full-path('src')}" />  
<property name="build.dir" value="D:\Subrat\Projects\WPF\WpfApplicationNAntTest\WpfApplicationNAntTest\bin\Debug" />  
<target name="clean" description="Delete automated build artifacts">  
    <delete dir="${build.dir}" if="${directory::exists(build.dir)}" failonerror="false"/>  
</target>   
<target name="make-builddir" description="Create build dir and build report dir">       
    <mkdir dir="${build.dir}" unless="${directory::exists(build.dir)}" />  
</target>   
<target name="release-properties">      
    <property name="release.dir" value="D:\Subrat\Projects\WPF\WpfApplicationNAntTest\WpfApplicationNAntTest\bin\Release"/>  
    <property name="wix.dir" value="D:\Subrat\Projects\WPF\WpfApplicationNAntTest\Lib\wix"/>  
</target>   
<target name="copy-to-release">     
    <mkdir dir="${release.dir}" failonerror="false"/>  
    <copy todir="${release.dir}">           
        <fileset basedir="${src.dir}">              
            <include name="*" />  
        </fileset>          
    </copy>     
</target>
<target name="build">
    <loadtasks assembly="D:\Subrat\Projects\WPF\WpfApplicationNAntTest\Lib\nantcontrib-0.85\bin\NAnt.Contrib.Tasks.dll"/>
    <msbuild project="D:\Subrat\Projects\WPF\WpfApplicationNAntTest\WpfApplicationNAntTest.sln">
        <property name="configuration" value="debug" />
        <property name="Platform" value="any cpu" />    
    </msbuild>
</target>
<target name="build-installer">     
    <!-- for wix preprocessor so that the location of pleats files are propagated into the wxs -->  
    <setenv name="pleats.dir" value="${release.dir}"/> 
    <delete>            
        <fileset>           
            <include name="${wix.dir}/*.wixobj"/>
    </fileset>          
    </delete>       
    <exec program="${wix.dir}\candle.exe" workingdir=".\wix" commandline="SampleFirst.wxs " /> 
    <exec program="${wix.dir}\light.exe" workingdir=".\wix" commandline="-ext WixUIExtension -cultures:en-us SampleFirst.wixobj -out ${release.dir}\pleats.msi"/> 
</target>   
</project>

我正在使用我在 wix 教程中获得的示例 wxs 文件。

 <?xml version='1.0' encoding='windows-1252'?>
 <Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>
   <Product Name='Foobar 1.0' Id='C2B662FC-82AA-11DF-93D4-6B70DFD72085' UpgradeCode='CE3E5F1C-82AA-11DF-A42F-7170DFD72085'
Language='1033' Codepage='1252' Version='1.0.0' Manufacturer='Acme Ltd.'>
<Package Id='*' Keywords='Installer' Description="Acme's Foobar 1.0 Installer"
  Comments='Foobar is a registered trademark of Acme Ltd.' Manufacturer='Acme Ltd.'
  InstallerVersion='100' Languages='1033' Compressed='yes' SummaryCodepage='1252' />

<Media Id='1' Cabinet='Sample.cab' EmbedCab='yes' DiskPrompt="CD-ROM #1" />
<Property Id='DiskPrompt' Value="Acme's Foobar 1.0 Installation [1]" />

<Directory Id='TARGETDIR' Name='SourceDir'>
  <Directory Id='ProgramFilesFolder' Name='PFiles'>
    <Directory Id='Acme' Name='Acme'>
      <Directory Id='INSTALLDIR' Name='Foobar 1.0'>

        <Component Id='MainExecutable' Guid='DD4C895C-82AA-11DF-941D-8370DFD72085'>
          <File Id='FoobarEXE' Name='WpfApplicationNAntTest.exe' DiskId='1' Source='D:\Subrat\Projects\WPF\WpfApplicationNAntTest\WpfApplicationNAntTest\bin\Debug\WpfApplicationNAntTest.exe' KeyPath='yes'>
            <Shortcut Id="startmenuFoobar10" Directory="ProgramMenuDir" Name="Foobar 1.0" WorkingDirectory='INSTALLDIR' Icon="WpfApplicationNAntTest.exe" IconIndex="0" Advertise="yes" />
            <Shortcut Id="desktopFoobar10" Directory="DesktopFolder" Name="Foobar 1.0" WorkingDirectory='INSTALLDIR' Icon="WpfApplicationNAntTest.exe" IconIndex="0" Advertise="yes" />
          </File>
        </Component>

        <!--<Component Id='HelperLibrary' Guid='YOURGUID-6BE3-460D-A14F-75658D16550B'>
          <File Id='HelperDLL' Name='Helper.dll' DiskId='1' Source='Helper.dll' KeyPath='yes' />
        </Component>

        <Component Id='Manual' Guid='YOURGUID-574D-4A9A-A266-5B5EC2C022A4'>
          <File Id='Manual' Name='Manual.pdf' DiskId='1' Source='Manual.pdf' KeyPath='yes'>
            <Shortcut Id="startmenuManual" Directory="ProgramMenuDir" Name="Instruction Manual" Advertise="yes" />
          </File>
        </Component>-->

      </Directory>
    </Directory>
  </Directory>

  <Directory Id="ProgramMenuFolder" Name="Programs">
    <Directory Id="ProgramMenuDir" Name="Foobar 1.0">
      <Component Id="ProgramMenuDir" Guid="E510F3DA-82AA-11DF-8814-8970DFD72085">
        <RemoveFolder Id='ProgramMenuDir' On='uninstall' />
        <RegistryValue Root='HKCU' Key='Software\[Manufacturer]\[ProductName]' Type='string' Value='' KeyPath='yes' />
      </Component>
    </Directory>
  </Directory>

  <Directory Id="DesktopFolder" Name="Desktop" />
</Directory>

<Feature Id='Complete' Level='1'>
  <ComponentRef Id='MainExecutable' />
  <!--<ComponentRef Id='HelperLibrary' />
  <ComponentRef Id='Manual' />-->
  <ComponentRef Id='ProgramMenuDir' />
</Feature>

<Icon Id="WpfApplicationNAntTest.exe" SourceFile="WpfApplicationNAntTest.exe" />
<UIRef Id="WixUI_Minimal" />
 </Product>
 </Wix>

当我尝试制作安装程序时,出现此错误 -

系统找不到文件 WpfApplicationNAntTest.exe

我对 Nant 或 wix 不太了解,因为我是新手。请帮忙。

I am trying to create an installer for my project using NAnt.
this is how my build script looks like

<?xml version="1.0"?>
<project name="pleats" default="build-release" xmlns="http://nant.sf.net/release/0.85/nant.xsd">

<target name="build-release" depends="clean, make-builddir, build, release-properties, copy-to-release, build-installer" />
<property name="tools.dir" value="${path::get-full-path('tools')}" />  
<property name="src.dir" value="${path::get-full-path('src')}" />  
<property name="build.dir" value="D:\Subrat\Projects\WPF\WpfApplicationNAntTest\WpfApplicationNAntTest\bin\Debug" />  
<target name="clean" description="Delete automated build artifacts">  
    <delete dir="${build.dir}" if="${directory::exists(build.dir)}" failonerror="false"/>  
</target>   
<target name="make-builddir" description="Create build dir and build report dir">       
    <mkdir dir="${build.dir}" unless="${directory::exists(build.dir)}" />  
</target>   
<target name="release-properties">      
    <property name="release.dir" value="D:\Subrat\Projects\WPF\WpfApplicationNAntTest\WpfApplicationNAntTest\bin\Release"/>  
    <property name="wix.dir" value="D:\Subrat\Projects\WPF\WpfApplicationNAntTest\Lib\wix"/>  
</target>   
<target name="copy-to-release">     
    <mkdir dir="${release.dir}" failonerror="false"/>  
    <copy todir="${release.dir}">           
        <fileset basedir="${src.dir}">              
            <include name="*" />  
        </fileset>          
    </copy>     
</target>
<target name="build">
    <loadtasks assembly="D:\Subrat\Projects\WPF\WpfApplicationNAntTest\Lib\nantcontrib-0.85\bin\NAnt.Contrib.Tasks.dll"/>
    <msbuild project="D:\Subrat\Projects\WPF\WpfApplicationNAntTest\WpfApplicationNAntTest.sln">
        <property name="configuration" value="debug" />
        <property name="Platform" value="any cpu" />    
    </msbuild>
</target>
<target name="build-installer">     
    <!-- for wix preprocessor so that the location of pleats files are propagated into the wxs -->  
    <setenv name="pleats.dir" value="${release.dir}"/> 
    <delete>            
        <fileset>           
            <include name="${wix.dir}/*.wixobj"/>
    </fileset>          
    </delete>       
    <exec program="${wix.dir}\candle.exe" workingdir=".\wix" commandline="SampleFirst.wxs " /> 
    <exec program="${wix.dir}\light.exe" workingdir=".\wix" commandline="-ext WixUIExtension -cultures:en-us SampleFirst.wixobj -out ${release.dir}\pleats.msi"/> 
</target>   
</project>

I am using the sample wxs file i got in wix tutorial.

 <?xml version='1.0' encoding='windows-1252'?>
 <Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>
   <Product Name='Foobar 1.0' Id='C2B662FC-82AA-11DF-93D4-6B70DFD72085' UpgradeCode='CE3E5F1C-82AA-11DF-A42F-7170DFD72085'
Language='1033' Codepage='1252' Version='1.0.0' Manufacturer='Acme Ltd.'>
<Package Id='*' Keywords='Installer' Description="Acme's Foobar 1.0 Installer"
  Comments='Foobar is a registered trademark of Acme Ltd.' Manufacturer='Acme Ltd.'
  InstallerVersion='100' Languages='1033' Compressed='yes' SummaryCodepage='1252' />

<Media Id='1' Cabinet='Sample.cab' EmbedCab='yes' DiskPrompt="CD-ROM #1" />
<Property Id='DiskPrompt' Value="Acme's Foobar 1.0 Installation [1]" />

<Directory Id='TARGETDIR' Name='SourceDir'>
  <Directory Id='ProgramFilesFolder' Name='PFiles'>
    <Directory Id='Acme' Name='Acme'>
      <Directory Id='INSTALLDIR' Name='Foobar 1.0'>

        <Component Id='MainExecutable' Guid='DD4C895C-82AA-11DF-941D-8370DFD72085'>
          <File Id='FoobarEXE' Name='WpfApplicationNAntTest.exe' DiskId='1' Source='D:\Subrat\Projects\WPF\WpfApplicationNAntTest\WpfApplicationNAntTest\bin\Debug\WpfApplicationNAntTest.exe' KeyPath='yes'>
            <Shortcut Id="startmenuFoobar10" Directory="ProgramMenuDir" Name="Foobar 1.0" WorkingDirectory='INSTALLDIR' Icon="WpfApplicationNAntTest.exe" IconIndex="0" Advertise="yes" />
            <Shortcut Id="desktopFoobar10" Directory="DesktopFolder" Name="Foobar 1.0" WorkingDirectory='INSTALLDIR' Icon="WpfApplicationNAntTest.exe" IconIndex="0" Advertise="yes" />
          </File>
        </Component>

        <!--<Component Id='HelperLibrary' Guid='YOURGUID-6BE3-460D-A14F-75658D16550B'>
          <File Id='HelperDLL' Name='Helper.dll' DiskId='1' Source='Helper.dll' KeyPath='yes' />
        </Component>

        <Component Id='Manual' Guid='YOURGUID-574D-4A9A-A266-5B5EC2C022A4'>
          <File Id='Manual' Name='Manual.pdf' DiskId='1' Source='Manual.pdf' KeyPath='yes'>
            <Shortcut Id="startmenuManual" Directory="ProgramMenuDir" Name="Instruction Manual" Advertise="yes" />
          </File>
        </Component>-->

      </Directory>
    </Directory>
  </Directory>

  <Directory Id="ProgramMenuFolder" Name="Programs">
    <Directory Id="ProgramMenuDir" Name="Foobar 1.0">
      <Component Id="ProgramMenuDir" Guid="E510F3DA-82AA-11DF-8814-8970DFD72085">
        <RemoveFolder Id='ProgramMenuDir' On='uninstall' />
        <RegistryValue Root='HKCU' Key='Software\[Manufacturer]\[ProductName]' Type='string' Value='' KeyPath='yes' />
      </Component>
    </Directory>
  </Directory>

  <Directory Id="DesktopFolder" Name="Desktop" />
</Directory>

<Feature Id='Complete' Level='1'>
  <ComponentRef Id='MainExecutable' />
  <!--<ComponentRef Id='HelperLibrary' />
  <ComponentRef Id='Manual' />-->
  <ComponentRef Id='ProgramMenuDir' />
</Feature>

<Icon Id="WpfApplicationNAntTest.exe" SourceFile="WpfApplicationNAntTest.exe" />
<UIRef Id="WixUI_Minimal" />
 </Product>
 </Wix>

when i am trying to make an installer i am geting this error -

the system cannot find the file WpfApplicationNAntTest.exe

i dont have much idea about Nant or wix as i am new to this. Please help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

扭转时空 2024-09-14 14:11:37

我认为您需要在 Icon 元素、SourceFile 属性中指定 WpfApplicationNantTest.exe 所在位置的完整路径。

像这样的东西:

<Icon 
 Id="WpfApplicationNAntTest.exe"      
 SourceFile="D:\Subrat\Projects\WPF\WpfApplicationNAntTest\bin\debug\WpfApplicationNAntTest.exe" />

I think you need to specify the full path in the Icon element, SourceFile attribute to where the WpfApplicationNantTest.exe is.

Something like:

<Icon 
 Id="WpfApplicationNAntTest.exe"      
 SourceFile="D:\Subrat\Projects\WPF\WpfApplicationNAntTest\bin\debug\WpfApplicationNAntTest.exe" />
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文