I can seem to get msbuild to build unsafe code blocks

流过昼夜 提交于 2019-12-12 10:35:24

问题


msbuild doesn't seem to allow me build unsafe blocks even though my .csproj specify:

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    ...
    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>

my build command is:

msbuild myProject.sln /p:Configuration=Release /p:Platform="Any CPU" /t:Clean,Build

回答1:


You showed that the property is set for the Debug configuration. One option is that it's missing for the Release configuration.

Also you specified the platform on the command line as "Any CPU" (with a space), while the build file requires "AnyCPU". This might also cause it to not being picked up.




回答2:


I added /p:AllowUnsafeBlocks=true to MSBuild command, as follow:

MSBuild some-project.csproj /p:AllowUnsafeBlocks=true

If you are in VSTS, you could just include the /p:AllowUnsafeBlocks=true in the parameter.

This works for me.



来源:https://stackoverflow.com/questions/38992374/i-can-seem-to-get-msbuild-to-build-unsafe-code-blocks

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!