0

Is there someway to get MSBuild to skip over missing files when using /p:OutDir?

I am working with TeamCity to continuously build a large webproject. I have written a program that handles our continuous deployment but I am running into an issue with MSbuild. I am using the property switch OutDir to output my needed web files.

Here is my msbuild command:

msbuild project.sln /property:Configuration=Release /property:OutDir=R:\BuildOutput\

MSBuild is failing with OutDir because there are files missing. Example:

error MSB3021: Unable to copy file "Api\Js\excanvas.min.js" to "R:\BuildOutput\_PublishedWebsites\Web\Api\Js\excanvas.min.js". Could not find file 'Api\Js\excanvas.min.js'.

It's a very large and old project with lots of missing files. Is there someway to get MSBuild to skip over these files and/or ignore these errors.

Thanks, any help will be appreciated.

Adding the missing files is a quick fix, but I don't want to add all the missing files every time we run into this issue.

Patrick Lorio
  • 5,520
  • 11
  • 45
  • 74

1 Answers1

4

The problem here is that your csproj is pointing, either explicitly or implicitly to files that don't exist

/p:OutDir just changes the location of something that's already happening.

So the unfortunate answer is... go fix that and don't blame the messenger.

EDIT: BTW adding /v:diag to the MSBuild invocation args will give you complete dumps of item lists as they are computed during the processing

Ruben Bartelink
  • 59,778
  • 26
  • 187
  • 249
  • The odd thing is that when the project is compiled with Visual Studio it doesn't complain of missing files - or is at least able to compile the project regardless. As I understand that Visual Studio is just using MsBuild you'd think there must be a way to not worry about missing files. – Robin Winslow Jan 30 '13 at 16:18
  • @RobinWinslow There are a variety of aspects of builds that are stubbed out or optimised when `$(BuildingInsidevisualStudio)` == `true`. One key one is `MvcBuildviews` - go search on that. But the real answer is that it's MSBuild scripts all the way down and you can turn on diags to get it to tell you who is (or isnt) doing what when. Then you see how that bit can be influenced to do your bidding. And go buy Inside MSBuild - nobody ever regrets that! – Ruben Bartelink Jan 30 '13 at 22:05
  • Quick response to such an old question. Thanks. I'm not gonna buy nothing though. I really dislike how answers from Microsoft stack developers so often involve buying software or books. Is there any way, without buying software, that I can inspect which properties VS is using to build? – Robin Winslow Jan 31 '13 at 08:28
  • Parameters in this question seem to work: http://stackoverflow.com/questions/3412900/how-can-i-publish-site-from-command-line-with-some-publish-profile – Robin Winslow Jan 31 '13 at 08:34
  • @RobinWinslow The diagnostics facilities are built in. While there is a Debugger facility I've never used it or needed it. The book for me is a must have - there is no intro documentation which explains MSBuild sufficiently *including debugging and diagnostics* which comes close - see http://stackoverflow.com/a/1339390/11635 It costs a lot less than you wasting your time on basics or trying to use SO and reading snippets of info on blogs in varying styles to debug stuff that should be simple – Ruben Bartelink Jan 31 '13 at 10:24