Our prod and dev machines are running .Net 4.5 but our build servers are .Net 4.0. We are targeting .Net 4.0 and Im trying to assess the impact of building on a machine with 4.0. In prod at runtime I know it will use 4.5 assemblies but...
Ive read the document from MS about the breaking changes in VS 2012 but Im trying to understand how this works under the covers. I can replicate the problem for the lambda example. When I run the app on a 4.0 and 4.5 server it behaves the same. I would have thought the runtime would fix the issue in 4.5. http://msdn.microsoft.com/en-us/library/vstudio/hh678682(v=vs.110).aspx.
I have also read about the compatibility issues with 4.5: http://msdn.microsoft.com/en-us/library/hh367887%28v=vs.110%29.aspx
At compile time I believe it uses references from C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0 and at runtime it uses C:\Windows\Microsoft.NET\Framework\v4.0.30319.
My question is how does VS behave differently in 2010 vs 2012. Is that due to it using a different MSBuild.exe or a different CSC.exe? Ive run this through process monitor but its not clear because it shows MSBuild in program files but I cant find it.
I can replicate the problem for the lambda example. When I run the app on a 4.0 and 4.5 server it behaves the same.
If you mean the change in behaviour in C# when it comes to capturing the iteration variable in a foreach
loop, that is not a framework matter at all. It's a compiler difference. If you use a C# 5 compiler, you'll get the new behaviour - if you use a C# 4 compiler, you'll get the old behaviour. You could be targeting .NET 2.0 and executing against a machine which only has .NET 2.0 on it, and you'd still get the new behaviour if you compile with a C# 5 compiler.
Now if you've only got .NET 4.0 installed on your build servers, they will be using the C# 4 compiler. Basically, your options are:
This is very specific to this particular issue, however. Other compatibility issues are likely to have different requirements.