MSBuild question

  • Thread starter Thread starter minorguy
  • Start date Start date
M

minorguy

I have a general question about MSBuild (which I know little about so far)
and I hope this is the right newsgroup. I can read the reference
documentation about MSBuild, but it's not really telling me what I want to
know. Perhaps someone can point me in the right direction.

We have several projects, mostly C++, that we develop with Visual Studio
2005. I would like to automate this process. All of the targets, executables
and DLLs, need to be built and then copied along with other files to a final
directory somewhere to form the final product. Ok, that much seems easy
enough. I presume I can call MSBuild from some script language or even C# to
automate things. I don't think I need to manually create an MSBuild project
file because we work from within the VS2005 IDE just fine.

But in order to copy the target file after it's been built, I need to know
where it is. How can I know from the automation point-of-view? Often, when
we work and debug from the VS2005 IDE we'll set the output directory to
C:\Windows\system32 for convenience because that's where the file installs
to in the final product, so the compile/debug cycle is easier. Or we may
not. Or we may change the output filename.

So from the automation/build point-of-view, I need to find the output file
for any given project programmatically. So far, the only way I can see to do
this is to parse the .proj file. But even then it's not so straightforward.
Sometimes that info isn't in the .proj file at all if you've left the linker
output file setting to the default. Or, another alternative would be to
override just the linker output file location when building from MSBuild. Is
that possible?

I get the feeling I may going about this from the wrong direction. Am I?
What's the best way to approach this?

Thanks for any comments.
 
Thanks Tod! Great reference and I'll definitely use it.



I'm thinking that I need to use VCBuild.exe directly instead of MSBuild.
MSBuild seems good if you want to control your build by manually editing a
text file like you would a makefile. But in our case, we usually set all
project settings from within VS2005. So we don't need to deal with settings
at build time. The only thing I need to do is invoke the build process and
then copy the output file somewhere.



I think I can parse the C++ project file to get the output file name and
location. I don't see any documentation to confirm this, so I'm starting out
by assumption. If the "Outputfile" linker property is not set, then I assume
the default location is defined by the "OutputDirectory" property and
default name is the same as the project name. I'm going to try that and see
how it goes.



Unfortunately, I may have to change all this in the future since C++ will
become directly buildable under MSBuild in the next VS version. The .vcproj
format will most likely change.
 
Back
Top