Error MSB4185: “System.Globalization.CultureInfo” has not been enabled for execution

。_饼干妹妹 提交于 2019-12-05 02:57:45

I own MSBuild (and this code). It's an error originating in the file microsoft.csharp.targets, as the error message probably says. In there is a property function:

$([System.Globalization.CultureInfo]::CurrentUICulture.Name)

What the error means is that it thinks that this function isn't in MSBuild's "safe list". These are selected functions that have no side effects. (If you want to use any function, you must have an environment variable MSBUILDENABLEALLPROPERTYFUNCTIONS=1).

I really don't know why this would appear unless somehow you're using the 4.5 microsoft.csharp.targets with the 4.0 microsoft.build.dll (which didn't have it in the safe list). I haven't received reports of this except in connection with Monodevelop.

Excuse my naivety, but I'm assuming Monodevelop is using the Microsoft .NET Framework with the Microsoft MSBuild and not a reimplementation of that.

Dan

The working solution for me is this:

Open a CMD and run this command on it: setx MSBUILDENABLEALLPROPERTYFUNCTIONS 1

Another solution I think is available is installing Mono Runtime and set it as your default CLR runtime from Tools -> Options -> .NET Runtimes.

After uninstalling .NET Framework 4.5 RC from my Windows 7 machine, this error disappeared. Of course make sure you have valid .NET runtime after you uninstall 4.5.

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