Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / .NET SDK / May 2006

Tip: Looking for answers? Try searching our database.

MSBuild Command line Question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ME - 18 May 2006 17:53 GMT
I have a need to generate both the DLL version of my application and an EXE
version.  I would like to build both of them with a single call "build".

One of the ideas I have come up with is to fire off MSBuild in the
PostBuildEvent of the project.  I think it may work however I am having some
command line issues with msbuild.

The project I have is setup to build the DLL version of the app by default.
In the project's PostBuildEvent I add the following msbuild command:

"msbuild.exe /t:build $(ProjectPath) /p:outputtype=winexe;postbuildevent="

The trouble is that when the msbuild command fires it attempts to build ALL
the projects as EXEs, including the dependancies.  How can I make msbuild
build ONLY the main project as an EXE when the project file is setup to
build a DLL?  (Note that the "postbuildevent=" property in the command is
used to stop the build from entering a constant build loop and is thus
required.)

Thanks,

Matt
Ben Voigt - 25 May 2006 00:32 GMT
>I have a need to generate both the DLL version of my application and an EXE
>version.  I would like to build both of them with a single call "build".
[quoted text clipped - 15 lines]
> command is used to stop the build from entering a constant build loop and
> is thus required.)

I guess by letting studio build the .exe and msbuild generate the .dll you
would have a solution... however you would still build all the dependencies
twice.

Do you have a separate project configuration?  I think you should build a
different configuration instead of specifying output type.  Instead of
"Release" and "Debug", you would get "Release EXE", "Debug EXE", "Release
DLL" (maybe "Debug DLL" but probably not needed).

> Thanks,
>
> Matt
ME - 27 May 2006 02:46 GMT
Thanks for your reply, the method you suggested may work (I shall have to
try in the next few days).  I am curious though about your project
configuration statement.  I can not seem to figure out how to specify the
output type for a specific project configuration in VS 2005.  How is
accomplished in VS 2005?  The "Configuration" combo is disabled when I view
the project properties (at least on the Application tab).  I agree that this
approach would be the ideal method, I just could figure out how to do it.

Thanks,

Matt

>>I have a need to generate both the DLL version of my application and an
>>EXE version.  I would like to build both of them with a single call
[quoted text clipped - 30 lines]
>>
>> Matt
ME - 27 May 2006 21:13 GMT
I thought I would post the answer to my msbuild question.  After taking Ben
Voigt's advice I came up with the following PostBuildEvent that I can now
include in every EXE project that I want to also be a DLL:

1) I specify the default project output as Windows Application in the
project properties.

2) I specify the following PostBuildEvent command excluding the brackets:

[C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\msbuild.exe /t:build
$(ProjectPath)
/p:outputtype=library;outputpath=$(OutDir)DLL;postbuildevent=]

3) I Set the PostBuildEvent to build on successfull build only.

Hopefully that may help someone else.  Note that I specify a SEPERATE
outputpath for the DLL in the command above.  Also note that the
"postbuildevent=" property in the command above disables the second
postbuildevent that will occur and is required or the build will never end.

Thanks,

Matt

> Thanks for your reply, the method you suggested may work (I shall have to
> try in the next few days).  I am curious though about your project
[quoted text clipped - 43 lines]
>>>
>>> Matt
ME - 27 May 2006 21:25 GMT
One more thing I have found if you specify the $(ProjectPath) do so in
quotes like this:

[C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\msbuild.exe /t:build
"$(ProjectPath)"
/p:outputtype=library;outputpath="$(OutDir)DLL";postbuildevent=]

That way if you have paths with spaces the command will not fail.  The
/t:build switch can also be removed completely if you want.

Thanks,

Matt

>I thought I would post the answer to my msbuild question.  After taking Ben
>Voigt's advice I came up with the following PostBuildEvent that I can now
[quoted text clipped - 68 lines]
>>>>
>>>> Matt
Ben Voigt - 29 May 2006 14:03 GMT
> Thanks for your reply, the method you suggested may work (I shall have to
> try in the next few days).  I am curious though about your project
[quoted text clipped - 4 lines]
> that this approach would be the ideal method, I just could figure out how
> to do it.

Well, I created a new project configuration (Build menu->Configuration
Manager, select a project, drop-down the configuration list next to the
project name, click New...) and changed the output type... studio changed it
for all configurations.  So the GUI gets in the way.  However, if you edit
the .csproj file, you'll see sections looking like:

<PropertyGroup>

<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>

...

<OutputType>WinExe</OutputType>

...

</PropertyGroup>

This should be pretty self-explanatory, just set different outputtype in the
project file, and hopefully studio won't automatically overwrite it to make
them match.

> Thanks,
>
[quoted text clipped - 34 lines]
>>>
>>> Matt

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.