2013-09-27 83 views
3

如何使用xbuild编译使用unsafe代码的Visual Studio 2010解决方案?如何编译使用不安全代码的解决方案?

目前我得到这个错误:

Implementation/MaximumImageColorClassifier.cs(35,13): error CS0227: Unsafe code requires the `unsafe' command line option to be specified

但运行:

xbuild -unsafe [solution file]

或:

xbuild /unsafe [solution file]

给出了一个错误:

MSBUILD: error MSBUILD0004: Too many project files specified

xbuild帮助表明这是正确的语法:

xbuild /? ... xbuild [options] [project-file]

但没有unsafe选项,并没有“通用”选项提供一些编译标志。

我看到了这个问题:Can I pass an argument to msc through xbuild on the command line?但它没有明确的答案,也许有不安全的代码的特定解决方法?

另外,在我的情况下,xbuild正在使用dmcs编译器。

回答

7

最终我自己找到了解决方案。它是把:

<AllowUnsafeBlocks>true</AllowUnsafeBlocks> 

csproj文件,在适当的PropertyGroup(相关xbuild使用来构建解决方案的配置)。它是正确的解释和unsafe代码编译好。

相关问题