re:Error executing command: msbuild

1,478 views
Skip to first unread message

corku mortoo

unread,
Jul 20, 2010, 1:22:04 PM7/20/10
to psake...@googlegroups.com
Hi All,
when i run this script,
***************************************************
properties {
$base_dir = resolve-path .
$build_dir = "$base_dir\build"
$buildartifacts_dir = "$build_dir\BuildArtifacts"
$sln_file = "$base_dir\Hello.sln"
}

task default -depends Compile

task Clean {
Write-Host "Cleaning solution" -ForegroundColor Green
remove-item -force -recurse $buildartifacts_dir -ErrorAction
SilentlyContinue
}

task Init -depends Clean {
Write-Host "Creating BuildArtifacts directory" -ForegroundColor Green
new-item $buildartifacts_dir -itemType directory
}

task Compile -depend Init {
Write-Host "Compiling ---" $sln_file -ForegroundColor Green
Exec { msbuild $sln_file "/p:OutDir=$build_artifacts_dir"
/p:Configuration=Release /v:quiet }
}
**********************************************************
i get the following error's -- what am i doing wrong?

C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(2868,9):
error MSB3023: No destination specified for Copy. Ple
ase supply either "DestinationFiles" or "DestinationFolder".
[D:\Nusrofe\GrokPSake2\ClassLibrary1\ClassLibrary1.csproj]
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(3471,9):
error MSB4044: The "FindUnderPath" task was not given
a value for the required parameter "Path".
[D:\Nusrofe\GrokPSake2\ClassLibrary1\ClassLibrary1.csproj]
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(2868,9):
error MSB3023: No destination specified for Copy. Ple
ase supply either "DestinationFiles" or "DestinationFolder".
[D:\Nusrofe\GrokPSake2\ClassLibrary2\ClassLibrary2.csproj]
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(3471,9):
error MSB4044: The "FindUnderPath" task was not given
a value for the required parameter "Path".
[D:\Nusrofe\GrokPSake2\ClassLibrary2\ClassLibrary2.csproj]
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(3471,9):
error MSB4044: The "FindUnderPath" task was not given
a value for the required parameter "Path".
[D:\Nusrofe\GrokPSake2\WpfApp\WpfApp.csproj]
******************************************************************
build2.ps1:Error executing command: msbuild $sln_file
"/p:OutDir=$build_artifacts_dir" /p:Configuration=Release /v:quiet
******************************************************************

Thanks --
Corku

James Allen

unread,
Jul 21, 2010, 10:50:55 AM7/21/10
to psake-users
Could be that you have mis spelled build artifacts dir parameter in
your call to msbuild -too many underscores?!

Mikael Henriksson

unread,
Jul 21, 2010, 10:59:29 AM7/21/10
to psake...@googlegroups.com
out dir needs a slash at the end "build_artifacts_dir\" otherwise psake (powershell) thinks it's a file.
Exec { msbuild $sln_file "/p:OutDir=$build_artifacts_dir\ /p:Configuration=Release /v:quiet }

--
You received this message because you are subscribed to the Google Groups "psake-users" group.
To post to this group, send email to psake...@googlegroups.com.
To unsubscribe from this group, send email to psake-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/psake-users?hl=en.


James Kovacs

unread,
Jul 26, 2010, 1:39:06 AM7/26/10
to psake...@googlegroups.com
Actually it's not psake that requires the slash. It's msbuild.exe. Just try running the msbuild command directly in PowerShell or cmd.exe and you'll see msbuild fails miserably if you don't have a slash at the end of the path for OutDir. (Just one of my many msbuild pet peeves.)

James
--
James Kovacs, B.Sc., M.Sc., MCSD, MCT
Microsoft MVP, ASP/ASP.NET
http://www.jameskovacs.com
jko...@post.harvard.edu | @jameskovacs
403-397-3177 (mobile)

Aaron Weiker

unread,
Jul 26, 2010, 11:40:56 AM7/26/10
to psake...@googlegroups.com
Has anyone done any work to make msbuild unnecessary? I personally would be really happy if I didn't have to call msbuild just to compile a solution. Then again, parsing project and solution files doesn't sound like a lot of fun.

-Aaron

Bill Barry

unread,
Jul 26, 2010, 1:27:12 PM7/26/10
to psake...@googlegroups.com
You can directly invoke csc.exe (or do it from .net code in a custom app if you so desire) and the various other tools, but doing so is generally more work than using msbuild (and has deeper inconsistencies). This is how mono projects were built before (not sure if that is still how monodevelop works or not, I haven't visited that scene in quite some time).

One of the major difficulties with working this way is that you need to manage your projects in two places (the .csproj files and the make script). Fortunately you can create an xsl script that can manage that for you if you have a simple project. Unfortunately, this adds more steps to your build (and more places where it can be broken). Technically if you really want to you can configure Visual Studio to execute your make script instead of invoking msbuild (and even get rid of project files in general), but doing so you lose a lot (much of the designer functionality is based on msbuild running against your projects, resharper is also very dependent on project files). If you want to go that route I would suggest a third party IDE anyway (look into sharpdevelop). Every step I have ever tried in that direction wound up with me in more pain than I am with msbuild. I am not sure if there is a better place out there (for any specific goal, yes there likely is a better way; for the general case of a solution that VS can handle, I have my doubts).

More information can be found by researching how NAnt works, as well as the files Microsoft.CSharp.targets and Microsoft.Common.targets within the \Windows\Microsoft.NET\Framework\v3.5 directory and looking at monodevelop/sharpdevelop.

The nice thing is, once you work around the difficulties of msbuild, you can for the most part forget about them.

James Kovacs

unread,
Jul 26, 2010, 11:09:21 PM7/26/10
to psake...@googlegroups.com
I second Bill's opinion. You can remove some of the pain of compiling via csc.exe by wildcarding files. (e.g. Pass csc.exe all *.cs files beneath $/src/app/Foo.Core and compile it into an assembly.) The biggest pain IMHO is managing references (both project and 3rd-party assemblies) in two places: one list to pass to csc.exe and the other within .csproj files. In my experience, the extra control you gain from manually scripting csc.exe is not worth the headache of debugging why something builds within VS (because it's calling msbuild) versus your build script calling csc.exe. This has been my experience with both NAnt, psake, Rake, and other build tools. That's why I recommend letting msbuild handle the compile and using psake (or Rake) script all the tasks around the compile.

Just my 2 cents...

James
--
James Kovacs, B.Sc., M.Sc., MCSD, MCT
Microsoft MVP, ASP/ASP.NET
http://www.jameskovacs.com
jko...@post.harvard.edu | @jameskovacs
403-397-3177 (mobile)


Jorge Matos

unread,
Jul 26, 2010, 11:34:10 PM7/26/10
to psake...@googlegroups.com
I agree with everything that everyone has said, that being said, one of the pain points I've seen in writing build scripts seems to be calling MSBuild - it's too easy to screw that up - I have some thoughts on how to remedy that with psake - I just haven't gotten to it yet :)

--
Jorge Matos
Senior .NET Architect, MCSD.NET, MCSD Visual Studio 6.0
(440) 666-3107
matos...@hotmail.com     
Blog: http://jorgelmatos.blogspot.com
--------------------------------------------------------------------------------
"Any intelligent fool can make things bigger and more complex...
It takes a touch of genius - and a lot of courage to
move in the opposite direction."... - Albert Einstein

Aaron Weiker

unread,
Jul 26, 2010, 11:52:45 PM7/26/10
to psake...@googlegroups.com
I did put together an extension script (I keep meaning to do a pull request), but it wraps up msbuild for me so that I can just use the following functions:

Compile-Solution
Clean-Solution
Publish-Website (uses robocopy, but for this project I didn't do anything fancy, I do have a really good solution I'm doing at work that I'll have to blog about where I do some crazy config management)


-Aaron


--

Jason Jarrett

unread,
Jul 27, 2010, 12:28:07 AM7/27/10
to psake...@googlegroups.com
Hello All,

FYI: I did some work to get csc to work when I was first learning powershell - it was really hard for me to get it to work at the time (mostly because my early powershell exposure, and I wrote a post on how I accomplished this - It's not pretty, but possibly a start for anyone)

Jorge Matos

unread,
Jul 27, 2010, 12:45:56 AM7/27/10
to psake...@googlegroups.com
Aaron,

I like what you've done - I'm thinking of something similar but a bit more generic.

--
Jorge Matos
Senior .NET Architect, MCSD.NET, MCSD Visual Studio 6.0
(440) 666-3107
matos...@hotmail.com     
Blog: http://matosjorge.spaces.live.com

Aaron Weiker

unread,
Jul 27, 2010, 1:02:24 AM7/27/10
to psake...@googlegroups.com
The trade off I had was verbosity over ease of reading. I'm sure I could play around with it some more and get both, but why mess with what works right now. Maybe when I set up another project I'll optimize further.


Reply all
Reply to author
Forward
0 new messages