Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3352840
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:04:44+00:00 2026-05-18T02:04:44+00:00

I can build the whole project by calling MSBuild from the command line: C:\MyProject>MSBuild

  • 0

I can build the whole project by calling MSBuild from the command line:

C:\MyProject>MSBuild MyProject.vcproj

However I didn’t find any information about compiling a single file.
In essence I would like to do something like

C:\MyProject>MSBuild MyProject.vcproj /t:Compile:MySourceFile.cpp

I do not want to directly use ‘cl.exe’ from the command line since that would force me to define all relevant command line options for cl.exe and all the environment variables, a task which MSBuild is already doing for me.

Is there any way to achieve that?

And please, do not suggest using ‘make’ or ‘ant’ or whatever, I specifically need MSBuild.
Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T02:04:44+00:00Added an answer on May 18, 2026 at 2:04 am

    MSBuild in VS2008 uses VCBuild to do the actual work, and VCBuild has no option I know of to build a single file. (with VS2010 this has changed, there you can actually invoke a compile of a single file using something like "/t:ClCompile "p:/SelectedFiles="main.cpp")

    I can come up with some ideas that will certainly work, but require some extra work and are not very straightforward:

    • you can msbuild have invoke devenv to compile a single file:

      devenv myproject.sln /Command "File.OpenFile myfile.cpp" /Command "Build.Compile" /Command "File.Exit"
      

      this does open the IDE window though, and will make it pretty hard to figure out if the compile actually succeeded or not.

    • have msbuild invoke a script/program which parses the vcproj and makes a copy with all sources under the Source File section removed except that one file you want to compile. Then have msbuild build that project using vcbuild /pass1 (pass1=compile only, no link).

    • always keep a response file having the same options as your vcproj and let msbuild invoke cl to compile the single file, using the response file. (making the response file is as simple as opening the project properties in VS, going to C++->CommandLine and copying everything listed)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an object that can build itself from an XML string, and write
Are there any good code profilers/analyzers for Erlang? I need something that can build
I'm using Hudson and Maven 2 for my automated build/CI. I can build fine
How can I build a loop in JavaScript?
Question Can I build a image database/library that has an e-commerce style checkout system
How can I build a numpy array out of a generator object? Let me
This may seem like a dumb question, but can an app build with c#
This problem crops up every now and then at work. Our build machine can
I'm using the Visual Editor to paint my Swing GUI. Can I dynamically build
Can anybody help me to build an XSD file to validate XMLs like these:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.