0

我正在使用 Msbuild 4.0。

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

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

以下是编译问题:

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

即使我尝试改变

工具版本到 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>
4

1 回答 1

1

我不知道您是否碰巧有任何运行 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" />
于 2012-01-19T14:23:08.083 回答