gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 10:55:38 25 4
gpt4 key购买 nike

我正在使用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" />

关于msbuild - MSbuild 4.0无法编译.Net 3.5项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8927266/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com