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.
 
發佈了19 篇原創文章 · 獲贊 6 · 訪問量 10萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章