VC2005下如何发布自己的程序

  
VC2005 下如何发布自己的程序。
 
作者:workingroy
2006-11-14
翻译自一篇文章:
 
在 MSDN的BLOG里看到一片文章,VC2005下讲的是如何发布自己的程序,使得没有安装VS2005的用户使用你开发的程序时不会因找不到必要的动态库而无法使用。
原文: Running C++ application built by VC++ Express on another computer
 
直接翻译重要的部分:
    我将演示一个人怎么样使用 MSMs在其他电脑上安装VC++ DLLs,我自己的电脑上已经安装了VC++ Express,并且我期望它能在其他没有安装VC++ Express的电脑上运行,我会这样做:
    1。我从 sourceforge.net下载WIX,这里是连接http://sourceforge.net/projects/wix。我会从这里下载我要使用的:http://prdownloads.sourceforge.net/wix/binaries-2.0.3220.0.zip?download。 但你可能会使用WiX的其他版本,可能是比我这个新的或者更老的版本。
    2。我将会把这个包解压缩到 D:/WiX/
    3。现在我将要打开 Visual Studio 2005的命令提示行(开始-程序-Visual C++ 2005 Express Edition>Visual Studio Tools>Visual Studio 2005 Command Prompt)
    4。我输入 uuidgen –n2 ,回车。这样就为我产生了2个UUIDs,在后面的第6步我将会用到。
    5。现在我将要在 D:/WiX创建2个XML文件,第一个是VCCRT.wxi, 第二个是VCCRT.wxs.
    6。首先我用以下内容创建了 D:/WIX/VCCRT.wxi :
       我在第 4步用uuidgen.exe为我产生了2个UUIDs来定义PRODUCT_ID 和 PACKAGE_ID。目的是为了让本人的读者避免和其他人使用相同的的UUID,因为我没有为我列出已经产生的UUID。
     
< Include >
       
<? define PRODUCT_ID=!!!! REPLACE WITH UUID1 FROM STEP 4 !!!!  ?>
       
<? define PACKAGE_ID=!!!! REPLACE WITH UUID2 FROM STEP 4 !!!!  ?>
</ Include >
     7。然后我用以下内容创建 D:/WIX/VCCRT.wxs:
     
<? xml version='1.0' ?>
<? include $(sys.SOURCEFILEDIR)VCCRT.wxi  ?>
< Wix  xmlns ='http://schemas.microsoft.com/wix/2003/01/wi'>
   
<Product 
                     Name
='MSI  to redistribute my app' 
                     Language
='1033'  Version ='1.0.0.0'  Manufacturer ='Me'>
       
<Package 
              Description
='MSI  to redistribute my app'
              Comments
='MSI  to redistribute my app'
              Manufacturer
='Me'
              
InstallerVersion ='300'
              
Compressed ='yes'  />
       
< Media  Cabinet ='VCCRT.cab'  EmbedCab ='yes'  />
       
< Directory  >
             
< Merge  Language ='0'  src ='D:Program  FilesCommon FilesMerge Modulesmicrosoft_vc80_crt_x86.msm' DiskId ='1'  />
             
< Merge  Policy' Language ='0'  src ='d:Program  FilesCommon FilesMerge Modulespolicy_8_0_Microsoft_VC80_CRT_x86.msm' DiskId ='1'  />
       
</ Directory >
      
< Feature  Title ='CRT  WinSXS' Level ='1'>
              
<MergeRef  />
              
< MergeRef  Policy'  />
       
</ Feature >
       
< InstallExecuteSequence >
              
< RemoveRegistryValues />
              
< RemoveFiles />
              
< InstallFiles />
              
< WriteRegistryValues />
       
</ InstallExecuteSequence >
   
</ Product >
</ Wix >
    8。现在我将要回到命令行,改变当前路径,编译并链接 MSI
------------------------------------------------------------------------------------- 
a.                             >cd d:/WiX
b.                             >candle.exe vccrt.wxs -out vccrt.wixobj
c.                             >light.exe vccrt.wixobj -out vccrt.msi
-------------------------------------------------------------------------------------
    9。这样 MSI就被创建了,它应该是这个文件D:/WiX/vccrt.msi.如果你遇见错误,关注后面的疑难解答章节。
    10。现在我拷贝我的程序和 vccrt.msi到其他我想这个程序能运行而又没有安装 VC++ Express 的电脑上,拷贝完后,我会先运行vccrt.msi再运行我的EXE程序。
    11。好了,现在我的程序运行很正常。如果你的程序在 MSI已经安装完成后不能启动,请关注后面的疑难解答章节。 
 
==================================================================================================
 
疑难解答(这个我就不翻译了,自己看吧
 
  1. Error message CNDL0054 from candle.exe
candle.exe : error CNDL0054 : The document element name 'Include' is invalid. A WiX source file must use 'Wix' as the document element name.
Cause: you have tried executing >candle.exe vccrt.wxi -out vccrt.wixobj instead of >candle.exe vccrt.wxs -out vccrt.wixobj
  1. Error message CNDL0009 from candle.exe
D:/WiX/vccrt.wxs(6) : error CNDL0009 : The Product/@Id attribute's value, '!!!! REPLACE WITH UUID FROM STEP 4 !!!! ', is not a legal guid value.
D:/WiX/vccrt.wxs(10) : error CNDL0009 : The Package/@Id attribute's value, '!!!! REPLACE WITH UUID FROM STEP 4 !!!!', is not a legal guid value.
Cause: Edit vccrt.wxi and replace !!!! REPLACE WITH UUID FROM STEP 4 !!!! with UUID generated in Step 4
 
  1. Error Message CNDLXXXX from candle.exe
Cause: No idea, mistake happen when you copy/pasted XML from this post. See WiX documentation for troubleshooting.
  1. Error on start of application either a message box that says "This application has failed to start because the application configuration is incorrect" or "The system cannot execute the specified program"
 
Cause: First, check that your application is built in Release mode. If it was Debug application, you will see OS errors that let you know that either msvcm80d.dll or msvcr80d.dll is not loaded. Second, check if you have deployed all Dependencies of this application. Use depends.exe to see dependencies of an application
  • Error message box while starting your application that says "To run this application you first must install .Net Framework of version v.2.0.xxxx".
 
Cause: You application contains managed code and depends on presence of .Net Framework. For C++ applications it means that it has been compiled as /clr, /clr:pure or /clr:safe. You have install .Net Framework.
 
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值