Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1085787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:43:58+00:00 2026-05-16T22:43:58+00:00

This is my first dive into MSBuild so I’m feeling pretty lost. The end

  • 0

This is my first dive into MSBuild so I’m feeling pretty lost.

The end goal is to run an executable which will output a file, and we want the output of the build to be that file. In this build there is no VS project what so ever.

The build is being run by TFS build services.

At this point all I’m trying to do is generate a file and have it copied to the drop folder.

Here is the contents of my .proj file

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

 <Target Name="Build">
  <Message Text="Output Dir: $(OutDir)" />
  <MakeDir Directories="$(OutDir)" />
  <Exec Command='dir /s > \\ANetworkPath\dir.txt
    dir /s > $(OutDir)Dir2.txt'/>
 </Target>
</Project>

The first command of writing dir to the network path succeeds, however it doesn’t show the existence of $(OutDir). So I thought I would try to create it with MakeDir. When the second dir command executes it errors because the path doesn’t exist.

TFS is running MSBuild with the following command

C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe /nologo /noconsolelogger "C:\Builds\1\Scratch\Test Build\Sources\user\Test\Build.proj" /m:1 /fl /p:SkipInvalidConfigurations=true  /p:OutDir="C:\Builds\1\Scratch\Test Build\Binaries\\" /p:VCBuildOverride="C:\Builds\1\Scratch\Test Build\Sources\user\Test\Build.proj.vsprops"  /dl:WorkflowCentralLogger,"C:\Program Files\Microsoft Team Foundation Server 2010\Tools\Microsoft.TeamFoundation.Build.Server.Logger.dll";"Verbosity=Normal;BuildUri=vstfs:///Build/Build/111;InformationNodeId=6570;TargetsNotLogged=GetNativeManifest,GetCopyToOutputDirectoryItems,GetTargetPath;TFSUrl=http://tfshost:8080/tfs/Test%20Collection;"*WorkflowForwardingLogger,"C:\Program Files\Microsoft Team Foundation Server 2010\Tools\Microsoft.TeamFoundation.Build.Server.Logger.dll";"Verbosity=Normal;"

The only output is in the file written on the network:

Directory of C:\Builds\1\Scratch\Test Build\Sources\user\Test

09/17/2010  10:53 AM    <DIR>          .
09/17/2010  10:53 AM    <DIR>          ..
09/17/2010  10:53 AM    <DIR>          A Directory
09/17/2010  10:53 AM                 0 Test.log
09/17/2010  10:53 AM               453 Test.proj
09/17/2010  10:53 AM               201 Test.proj.vsprops
               3 File(s)            654 bytes

 Directory of C:\Builds\1\Scratch\Test Build\Sources\user\Test\A Directory

09/17/2010  10:53 AM    <DIR>          .
09/17/2010  10:53 AM    <DIR>          ..
09/17/2010  10:53 AM                 9 A File.txt
09/17/2010  10:53 AM                15 Another File.txt
               2 File(s)             24 bytes

     Total Files Listed:
               5 File(s)            678 bytes
               5 Dir(s)  40,243,372,032 bytes free

Here is the build log:

Build started 9/17/2010 12:05:29 PM.
Project "C:\Builds\1\Scratch\Test Build\Sources\user\Test\Test.proj" on node 1 (default targets).
Build:
  Output Dir: C:\Builds\1\Scratch\Test Build\Binaries\
  dir /s > C:\Builds\1\Scratch\Test Build\Binaries\Dir2.txt
  The system cannot find the path specified.
C:\Builds\1\Scratch\Test Build\Sources\user\Test\Test.proj(24,3): error MSB3073: The command "dir /s > C:\Builds\1\Scratch\Test Build\Binaries\Dir2.txt" exited with code 1.
Done Building Project "C:\Builds\1\Scratch\Test Build\Sources\user\Test\Test.proj" (default targets) -- FAILED.

Build FAILED.

"C:\Builds\1\Scratch\Test Build\Sources\user\Test\Test.proj" (default target) (1) ->
(Build target) -> 
  C:\Builds\1\Scratch\Test Build\Sources\user\Test\Test.proj(24,3): error MSB3073: The command "dir /s > C:\Builds\1\Scratch\Test Build\Binaries\Dir2.txt" exited with code 1.

    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:01.14

Am I going about this completely wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T22:43:58+00:00Added an answer on May 16, 2026 at 10:43 pm

    Your code works fine in my computer.
    However : you should instantiate OutDir property either by passing it in Command-Line invokation :

    c:\WINDOWS\Microsoft.NET\Framework\v4.0\MSBuild.exe test.proj /p:OutDir=MyNewDir
    

    or with a PropertyGroup element :

    <?xml version="1.0" encoding="utf-8"?>
    <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    
      <PropertyGroup>
        <OutDir>MyNewDir</OutDir>
      </PropertyGroup>
    
     <Target Name="Build">
      <Message Text="Output Dir: $(OutDir)" />
      <MakeDir Directories="$(OutDir)" />
      <Exec Command='dir /s > \\ANetworkPath\dir.txt
        dir /s > "$(OutDir)\Dir2.txt"'/>
     </Target>
    </Project>
    

    Notice the \ added in the dir command.

    EDIT : I get it : you have a space in your output path. The command dir /s > my path\Dir2.txt is not gonna work unless you encapsulate the path with quotes. Try the following commands in the dos shell :

    mkdir C:\Builds\1\Scratch\Test Build\Binaries\
    mkdir "C:\Builds\1\Scratch\Test Build\Binaries\"
    

    You will notice the difference (the first line creates two directories one C:\Builds\1\Scratch\Test and one .\Build\Binaries). I edited my code above to add quotes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my first real dive into JavaScript. Sure I've used it before, but
This is my first crack at a method that is run periodically during the
I'm getting ready to dive into my first Core Data adventure. While evaluating the
So I'm just going to dive into this issue... I've got a heavily used
problem euler #5 i found the solution but i don't know why this first
This is my first post here and I wanted to get some input from
This is my first experience using the Zend Framework. I am attempting to follow
this is my first question to stackoverflow so here it goes... I use cruise
This is my first time attempting to call an ASP.NET page method from jQuery.
this is my first question here so I hope I can articulate it well

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.