I've recently upgraded to Visual Studio 2010. Now when I build projects I get a line that reads:
1> .NETFramework,Version=v4.0.AssemblyAttributes.cpp
I've learned that this is the result of the new build engine, msbuild.exe, but this file is actually auto-created and placed in my local temp directory (c:\Documents and Settings\me\Local Settings\Temp). Does anyone know why this file is created, and whether I can disable its creation?
BTW, it doesn't seem to have anything useful in it, to my mind. See below:
#using <mscorlib.dll>
[assembly: System::Runtime::Versioning::TargetFrameworkAttribute(L".NETFramework,Version=v4.0", FrameworkDisplayName=L".NET Framework 4")];
And occasionally, as reported http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/15d65667-ac47-4234-9285-32a2cb397e32, it causes problems. So any information on this file, and how I can avoid its auto-creation would be much appreciated. Thank you!
This is common to all languages (C#, VB, and F# have something similar too).
One way you can disable it is to override the GenerateTargetFrameworkMonikerAttribute target thusly:
<!-- somewhere after the Import of Microsoft.somelanguage.targets -->
<Target Name="GenerateTargetFrameworkMonikerAttribute" />
in your project file.
Take a look at c:\program files\msbuild\microsoft.cpp\v4.0\microsoft.buildsteps.targets. It contains the GenerateTargetFrameworkMonikerAttribute target, that's the one that generates the file. The Condition element determines when it runs, GenerateTargetFrameworkAttribute is the value. That will always be true if the project settings ask for a /clr build. The comment in the target is very misleading, the hoopla about precompiled header files has nothing to do with the purpose of the target.
The [TargetFrameworkAttribute] it generates in the .cpp helper file is important, that tells the CLR on the machine on which the program runs what minimum version of .NET needs to be present to successfully execute the program. Its primary use is to automatically launch the installer for the .NET version that's needed, very nice feature.
LNK4221 is common and has no teeth, you can ignore it. Sadly the linker does not provide a documented way to suppress warnings, basic issue is that it cannot be specific enough to suppress only this one. Suppressing the helper .cpp would require editing the .targets file and breaks the auto-install feature, I cannot recommend that.
I resolved this problem with the following steps:
Clean the solution
Close the solution
Type in run command %temp%
, delete all the files
Open the solution by clicking the project solution file from the folder where the project has been saved.
Do a rebuild on one of the projects. Then close Visual Studio 2010 (yes the entire development environment), and then re-open the solution file.
It seems that the rebuild, recreates the missing file, but Visual Studio doesn't notice it, so you have to close it down and re-open it for it to properly see the file again.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With