msbuild - MSbuild 4.0无法编译.Net 3.5项目

我正在使用Msbuild 4.0。

在我们的项目中,很少有解决方案具有.net 3.5项目。

当我通过Visual Studio编译它时,它可以工作。如果我使用Msbuild构建相同的对象,它将失败。

以下是编译问题:

错误:编译失败。无法加载一种或多种请求的类型。检索LoaderExceptions属性以获取更多信息。
来自HRESULT的异常:0x80131515

即使我尝试改变

toolsversion to 3.5



通过项目的附加属性。 [我正在使用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>

最佳答案

我不知道您是否碰巧有运行MSBuild的脚本运行程序。就个人而言,我正在使用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>



对于开发版本,我设置以下参数:
<property name="buildconfiguration" value="Debug"/>
<property name="debug.type" value="full" />

https://stackoverflow.com/questions/8927266/

相关文章:

jquery - MVC 4 : How to use the “partial validatio

objective-c - 初始化程序元素不是编译时常量错误

c# - 为什么尝试在WPF/C#中注册所有事件时出现构建错误?

c# - 引用的.NET程序集中的解析类型

visual-studio-2010 - XNA 4.0 Visual Studio 2010错误

gcc - 将 gcc vector::iterator 传递给函数有什么问题?

ruby-on-rails - 编译错误,意外的 kENSURE,预计 Rails 3 项目中出现

gcc - 使用arm-linux-gcc编译STLPort时发生未知错误

database - 为Windows和Linux编译64位sqlite

eclipse - 在Eclipse/STS中进行编译不会产生任何输出