gpt4 book ai didi

visual-studio - VS 2013 和 MSBuild

转载 作者:行者123 更新时间:2023-12-04 19:06:18 28 4
gpt4 key购买 nike

我最近升级到 Visual Studio 2013,这在使用 MSBuild(API 或 Executable with command line args)从外部构建时导致了背靠背问题

问题 #1
使用 MSBuild 构建时,它不会生成我们的单元测试所需的假程序集,这会导致构建失败。 Visual Studio 中的一个简单构建暂时修复了这个问题,直到需要生成新的假程序集。

问题 #2
运行代码分析时,它会提示以下内容:

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\CodeAnalysis\Microsoft.CodeAnalysis.targets(284,5): 
error MSB4127: The "CodeAnalysis" task could not be instantiated from the assembly "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\CodeAnalysis\.\FxCopTask.dll".

Please verify the task assembly has been built using the same version of the Microsoft.Build.Framework assembly as the one installed on your computer and that your host application is not missing a binding redirect for Microsoft.Build.Framework. Unable to cast object of type 'Microsoft.Build.Tasks.CodeAnalysis' to type 'Microsoft.Build.Framework.ITask'.

我的机器上只安装了 Visual Studio 2013,显然安装旧版本可以解决这个问题,但这不是我能做的。 (VS 2013 附带自己的 MSBuild 12.0,它位于与以前的 MSBuild 不同的目录中)。

我不确定为什么 Visual Studio 的行为与 MSBuild 有任何不同,我只是像这样指向解决方案文件......
msbuild.exe "path\solution.sln" /property:Configuration=Debug

最佳答案

因此,Visual Studio 2013 附带了新版本的 MSBuild,即 MSBuild 12.0。安装后,它会更改路径,以便默认使用新版本。

看起来您的解决方案是使用 Visual Studio 2012 编译的,您可以指定 msbuild.exe 的完整路径,例如

C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild "path\solution.sln"/property:Configuration=Debug

或通过在执行 msbuild 之前运行以下命令来设置 Visual Studio 2012 环境变量

"%VS110COMNTOOLS%"\vsvars32.bat//VS2012 环境变量

编辑:使用 MSbuild 12.0 程序集“C:\Program Files (x86)\MSBuild\12.0\Bin\”修复了代码分析错误的问题。

关于visual-studio - VS 2013 和 MSBuild,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23497304/

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