Tag Archives: msbuild

C++ Global _CRT_SECURE_NO_WARNINGS

I became extremely annoyed by thousands of these messages while running MSBuild:

c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\string.h(105) : 
see declaration of 'strcpy' SomeFile.cpp(###): 
warning C4996: 'strcpy': This function or variable may be unsafe. 
Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. 
See online help for details.

I looked for the online help, which doesn’t really exist for this specific warning. I did find the Security Features in the CRT article, but that was useless. Because I’m working on a shared project, I didn’t want to manually add this #define to every project. The workaround is to add it to the *.user.props file.

Add the ItemDefinitionGroup node below to C:\Users\Jschubert\AppData\Local\Microsoft\MSBuild\v4.0\Microsoft.Cpp.Win32.user.props:

<?xml version="1.0" encoding="utf-8"?> 
<Project DefaultTargets="Build" ToolsVersion="4.0"
         xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ItemDefinitionGroup>
    <ClCompile>
      <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
    </ClCompile>
    <ResourceCompile>
      <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
    </ResourceCompile>
  </ItemDefinitionGroup>
</Project>

And there you have thousands of annoying warnings disappear.

Because MSBuild always includes %(PreprocessorDefinitions) when chaining PreprocessorDefinitions, you can add any number of defines here to exist globally on your machine only.

Flattr this!

My Review of Inside the Microsoft® Build Engine

Originally submitted at O’Reilly

Your practical guide to using, customizing, and extending the build engine in Visual Studio 2010.


Quite a LOT of information

By Jim from Herndon, VA on 5/5/2011

 

5out of 5

Pros: Concise, Easy to understand, Accurate, Well-written, Helpful examples

Best Uses: Intermediate, Expert

Describe Yourself: Developer

I’ve reviewed this book as part of O’Reilly’s blogger program.

I have previously used MSBuild and Windows Installer XML for build and deploy scenarios. Before reading “Inside the Microsoft Build Engine”, I considered my understanding of MSBuild to be fairly in-depth. After reading through this book, I now realize that I’ve not used MSBuild to its full potential.

This book covers a lot, from the basics of ItemGroups and PropertyGroups, to writing custom tasks and loggers, to using MSBuild for the more complicated build process of Visual C++ projects.

Recently, I was on a team which used MSBuild and msdeploy.exe for building and deploying a web application. Researching and implementing a solution with proper configuration took the better part of two days. The last three chapters of this book cover web application build/deployment scenarios and would have been very useful if I had this book as a reference a few months ago.

(legalese)

Flattr this!