问题
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