之前的KB有提過Web Site Project裡因Namespace觀念改變而造成潛在類別名稱重覆的陷阱

如同該文結論,由於aspnet_merge.exe只會傳回模糊的Error Code=1,在大專案裡要找出哪個Class強碰是件艱鉅的工程,當時甚至還想要自己寫個工具程式去抓重覆類別。今天同事急著要Build Project,又遇到同樣的問題,但這次可沒時間慢慢去搞台潛盾機出來,快快去Google了一下,找到這瓶放在7-11的醬油。

如上圖,調整MSBuild project build ouput verbosity就可以看到較完整的訊息(網路上的文章說設成"Normal"即可,我發現得設成"Detailed"才行),如下所示,訊息中可以看到重覆的Class Name,要修正就簡單多了。

Task "AspNetMerge"
Running aspnet_merge.exe ...
Command:
C:\Program Files\MSBuild\Microsoft\WebDeployment\v8.0\aspnet_merge.exe "C:\Documents and Settings\jeffrey\My Documents\Visual Studio 2005\Projects\Blah_deploy\Debug" -prefix Blah -debug -copyattrs
The "AspNetMerge" task is using "aspnet_merge.exe" from "C:\Program Files\MSBuild\Microsoft\WebDeployment\v8.0\aspnet_merge.exe".
Utility to merge precompiled ASP.NET assemblies.
Copyright (c) Microsoft Corporation. All rights reserved.
An error occurred when merging assemblies: ILMerge.Merge: ERROR!!:
Duplicate type 'TheNameSpace.DuplicateClassName' found in assembly 'App_Web_jmntgiia'.
C:\Program Files\MSBuild\Microsoft\WebDeployment\v8.0\Microsoft.WebDeployment.targets(574,9): error MSB6006: "aspnet_merge.exe" exited with code 1.
Done executing task "AspNetMerge" -- FAILED.


Comments

# by 金旺

這篇真有用,今天用到囉!!!

Post a comment


79 - 51 =