As part of my current project, I had to build solution which contained both C++ and C# projects. C# project was written for target version of .NET 3.5. Whenever, I tried msbuild from command prompt, it complained ‘must declare a body because it is not marked abstract or extern’ for the property declarations in my C# classes. I have done a lot of research (Thanks to Google) to find a solution for this.
1. I ensured that the csproj file contains the target framework version of 3.5
<targetframeworkversion>v3.5</targetframeworkversion>
2. Tried to override version through msbuild parameters
/p:Configuration=Debug;TargetFrameworkVersion=v3.5 /toolsversion:3.5 /property:TargetFrameworkVersion=v3.5
3. Enabled diagnostic log information for msbuild and identified that csc.exe file from v2.0.50727 is picked up during the build (event though Microsoft.Common.targets is picked up from v3.5)
/v:diag
4. Did some more search and found out this thread from msdn. So the problem was in my environment COMPLUS_VERSION was set to v2.0.50727
I fixed the problem by setting environment variable 'COMPLUS_VERSION' value to empty. (Since my project file was already set for v3.5, clearing the environment variable helped me. Otherwise, you will need to set it to v3.5)
No comments:
Post a Comment