11

I'm looking to compile my Delphi 2010 project using MSBuild, but something isn't right, I just couldn't make MSBuild to compile my project.

I tried this command line:

"C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe" "C:\MyProject\Myapp.dproj" /t:Release

and this:

"C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe" "C:\MyProject\Myapp.dproj" /p:Configuration=Release /t:Release

But MSBuild won't recognize my build configuration!

I also changed [ rsvars.bat ] but it didn't work!

@SET BDS=C:\Program Files (x86)\Embarcadero\RAD Studio\7.0
@SET BDSCOMMONDIR=C:\Users\Public\Documents\RAD Studio\7.0
@SET FrameworkDir=C:\Windows\Microsoft.NET\Framework\v4.0.30319
@SET FrameworkVersion=v4.0.30319
@SET FrameworkSDKDir=
@SET PATH=%FrameworkDir%;%FrameworkSDKDir%;%PATH%
@SET LANGDIR=EN

The MSBuild error is:

C:\MyProject\Myapp.dproj : error MSB4057: The target "Release" does
not exist in the project.

Any help to get me build my app with MSBuild would be greatly appreciated.

(Yes, I'm fully aware of tools like FinalBuilder, I just want to learn how to do this with MSBuild)

Thanks!

9
  • Thank you, OK (1) I changed rsvars.bat back (but still can't compile :(), (2) DOS doesn't recognize msbuild without full path. Commented Feb 17, 2012 at 19:39
  • 3
    If you run the rsvars.bat file before running msbuild the windows console (which is not the same as DOS, as a side note) will recognize a plain call to 'msbuild.exe' as rsvars.bat modifies the PATH variable (see line 6). You can also permanently edit the environment variables - that way you don't have to run rsvars.bat every time. Commented Feb 17, 2012 at 19:41
  • 2. It certainly does recognise msbuild, if you run rsvars.bat before calling msbuild. Read the docs. They explain all of this. Commented Feb 17, 2012 at 19:44
  • Doh! Yes, I see now, I run the rsvars.bat (don't laugh! I was double-clicking on it before!) and now Chris's line works! Commented Feb 17, 2012 at 19:53
  • 1
    You need to delete the bogus file C:\Users\Admin\msbuild.exe. Commented Feb 17, 2012 at 20:25

2 Answers 2

14

You need to switch the parameters. The target parameter (/t) tells MSBuild which target to create. This can be either 'Make', 'Clean' or 'Build' (or a combination of those - seperate them with ';' in this case).

The property parameter (/p) forwards properties to the actual compiler. You can specify for example the configuration using /p:config=

So if you want to clean and then build a project using the release configuration, specify the paramters like this:

msbuild.exe "/t:Clean;Build" "/p:config=Release" Myapp.dproj
Sign up to request clarification or add additional context in comments.

4 Comments

Thank you, Chris but now I'm getting this:
Microsoft (R) Build Engine Version 4.0.30319.1 [Microsoft .NET Framework, Version 4.0.30319.1] Build started 2/17/2012 20:37:11 PM. Project "D:_Software\test.dproj" on node 1 (Clean;Build target(s)) . D:_Software\test.dproj : error MSB4057: The target "Clean" does no t exist in the project. Done Building Project "D:_Software\test.dproj" (Clean;Build target (s)) -- FAILED. Build FAILED. "D:_Software\test.dproj" (Clean;Build target) (1) -> D:_Software\test.dproj : error MSB4057: The target "Clean" does not exist in the project. 0 Warning(s) 1 Error(s)
@David Heffernan I'm using powershell, and it seperates commands by semicolons. That makes it necessary to put quotes around them. The standard console does not require this though
@chris alternative is to use /t twice (/t:clean /t:build) or use a back tick to escape the ; (/clean`;build)
1

Change /p:Configuration=Release to /p:config=Release

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.