2012-01-19 155 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" />