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。

































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已经安装完成后不能启动,请关注后面的疑难解答章节。
==================================================================================================
疑难解答(这个我就不翻译了,自己看吧
)
- 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
- 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
- Error Message CNDLXXXX from candle.exe
Cause: No idea, mistake happen when you copy/pasted XML from this post. See WiX documentation for troubleshooting.
- 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.