2012-01-19 67 views
0

我正在使用Msbuild 4.0。MSbuild 4.0無法編譯.net 3.5項目

在我們的項目中,很少有解決方案具有.net 3.5項目。

當我通過Visual Studio編譯它的作品。如果我使用Msbuild構建它,它會失敗。

以下是彙編問題:

錯誤:編譯失敗。無法加載一個或多個請求的類型。檢索LoaderExceptions屬性以獲取更多信息。從HRESULT 異常:0x80131515

即使我試圖改變

toolsversion至3.5

通過項的additionalproperties。 [我正在使用Msbuild任務來構建我的解決方案]

我們的Msbuild任務如下所示。

<Target Name="BuildDotNETSolutions" Condition="'$(Group)' != ''" DependsOnTargets="Init;GetNextVersionNumber"> 
    <!-- Complie solutions --> 
    <!-- Version property is useful for changing the Wix Msi version--> 
    <MSBuild Projects="@(Solution)" BuildInParallel="true" 
       Properties="Configuration=$(Configuration);PostbuildEvent=;Version=$(BuildNextVersionNumber)" 
       Condition="'%(Solution.Group)' == '$(Group)' And '%(Solution.Type)' == 'DotNET' And '%(Solution.IsRebuild)'=='$(IsRebuild)'"> 

     <Output 
         TaskParameter="TargetOutputs" 
         ItemName="BuildOutputs" /> 
    </MSBuild> 

我們通過屬性傳遞的解決方案文件中像下面

<Solution Include="$(Implementation)\MultiEvent.csproj;"> 
     <Group>Event</Group> 
     <AdditionalProperties> 
     ReferencePath=$(Implementation)\References; 
     ToolsVersion=3.5; 
     </AdditionalProperties> 
     <IsRebuild>True</IsRebuild> 
     <Type>DotNET</Type> 
    </Solution> 
+0

給我們的MSBuild的代碼和命令的樣本將有助於得到一個解決方案。 –

+0

@James Woolfenden:我已經更新了代碼和命令 – Samselvaprabu

回答

1

,如果你碰巧有運行的MSBuild任何腳本亞軍,我不知道。 Personnally,我使​​用NAnt,一切工作正常。我讀過(某處)MSBuild有時會做一些愚蠢的事情,通過添加屬性「TrackFileAccess」並將其設置爲「false」會有很大幫助。就我而言,它解決了這個問題。

如果它可以有任何幫助,我已經包含了我的NAnt構建任務。我希望它對你有用。

<!--******************************************************************************* 
Runs MSBuild to build the project solution 

Arguments: 
${MSBuild.exe}: Path to MSBuild.exe 
${project.solution}: the solution name to build 
${buildconfiguration}: The build configuration to trigger the build 
${build.dir} : The directory where to put builded files 

********************************************************************************--> 
<target name="run.msbuild" description="Rebuilds a given solution file"> 

<echo message="Rebuilding Solution ${project.solution}" /> 
<echo>${MSBuild.exe}</echo> 

<exec program="${MSBuild.exe}"> 
     <arg value="${project.solution}"/> 
    <arg line="/property:SignAssembly=${project.sign},AssemblyOriginatorKeyFile=${project::get-base-directory()}\${project.signature.file}" /> 
    <arg line="/property:OutDir=${build.dir}" /> 
    <arg line="/property:TrackFileAccess=false" /> 
    <arg line="/property:DebugType=${debug.type}" /> 
    <arg line="/property:Platform=&quot;Any CPU&quot;" /> 
    <arg line="/nologo" /> 
    <arg line="/verbosity:minimal" /> 
    <arg line="/property:Configuration=${buildconfiguration}"/> 
</exec> 

的發展累積的情況

,我設置以下PARAMS:

<property name="buildconfiguration" value="Debug"/> 
<property name="debug.type" value="full" />