# Create Directory/Run Dos Command- source path expansion

**URL:** https://www.finalbuilder.com/forums/t/create-directory-run-dos-command-source-path-expansion/5747
**Category:** Bugs
**Created:** [October 2, 2012, 3:41am UTC](https://www.finalbuilder.com/forums/t/create-directory-run-dos-command-source-path-expansion/5747 "2012-10-02T03:41:17Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![skermajo](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/s/bb73d2/32.png) [@skermajo](https://www.finalbuilder.com/forums/u/skermajo)
#### Post date: [October 2, 2012, 3:41am UTC](https://www.finalbuilder.com/forums/t/create-directory-run-dos-command-source-path-expansion/5747/1 "2012-10-02T03:41:17Z")

</div>

In the 'Create Folder' action, the following value the 'Path' results in 'MyDirecetory' being created directly in the workspace rather than under the source path:

$Source.MyRepo$\MyDirectory

Related, the 'Run DOS Command' action has a similar problem - the $Source$ just seems to be ignored:

$Source.MyRepo$\mybatchfile.bat

Results is a failed build, with the error:

'\mybatchfile.bat' is not recognized as an internal or external command,&nbsp;operable program or batch file.

---

<div class="post-metadata">

### Author: ![Vincent](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/vincent/32/938_2.png) [@Vincent](https://www.finalbuilder.com/forums/u/Vincent)
#### Post date: [October 2, 2012, 3:43am UTC](https://www.finalbuilder.com/forums/t/create-directory-run-dos-command-source-path-expansion/5747/2 "2012-10-02T03:43:55Z")

</div>

Ouch, we’ll get that fixed.

---

<div class="post-metadata">

### Author: ![Vincent](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/vincent/32/938_2.png) [@Vincent](https://www.finalbuilder.com/forums/u/Vincent)
#### Post date: [October 2, 2012, 3:56am UTC](https://www.finalbuilder.com/forums/t/create-directory-run-dos-command-source-path-expansion/5747/3 "2012-10-02T03:56:34Z")

</div>

Hi Joel   
  
 Can you show what your Repository Rules are for that stage.

---

<div class="post-metadata">

### Author: ![Vincent](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/vincent/32/938_2.png) [@Vincent](https://www.finalbuilder.com/forums/u/Vincent)
#### Post date: [October 2, 2012, 4:01am UTC](https://www.finalbuilder.com/forums/t/create-directory-run-dos-command-source-path-expansion/5747/4 "2012-10-02T04:01:14Z")

</div>

We’ve been looking at the source for this and it would seem to indicate that there is no source rule that matches the repository. I think we probably should be throwing an exception where a reference to $Source.repo$ is used when there are no matching repository rules.

---

<div class="post-metadata">

### Author: ![skermajo](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/s/bb73d2/32.png) [@skermajo](https://www.finalbuilder.com/forums/u/skermajo)
#### Post date: [October 2, 2012, 4:04am UTC](https://www.finalbuilder.com/forums/t/create-directory-run-dos-command-source-path-expansion/5747/5 "2012-10-02T04:04:00Z")

</div>

For that stage, I don't have any repository rules at all.&nbsp;I'm relying on the bat file being there from the repository rules in the stage before.

---

<div class="post-metadata">

### Author: ![skermajo](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/s/bb73d2/32.png) [@skermajo](https://www.finalbuilder.com/forums/u/skermajo)
#### Post date: [October 2, 2012, 4:05am UTC](https://www.finalbuilder.com/forums/t/create-directory-run-dos-command-source-path-expansion/5747/6 "2012-10-02T04:05:33Z")

</div>

Ok that makes sense. But in some cases wouldn't that mean that some source copies will be doubled up across stages - or is it smarter than that?

---

<div class="post-metadata">

### Author: ![Vincent](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/vincent/32/938_2.png) [@Vincent](https://www.finalbuilder.com/forums/u/Vincent)
#### Post date: [October 2, 2012, 4:24am UTC](https://www.finalbuilder.com/forums/t/create-directory-run-dos-command-source-path-expansion/5747/7 "2012-10-02T04:24:10Z")

</div>

If it’s running on the same agent as a prior stage and the rules are the same, it’s smart enough to only copy what it needs (the cache on the agent is a mercurial repository, and it’s very effecient). The issue here is that if there are no rules for the stage then the agent doesn’t know where to look, and it can’t just uses the rules from the previous stage as that may have run on a different agent   
  
 The whole reason we implemented the repository rules (fairly recently) was to cut down on needless IO copying the source code into the workspace on stages where it might not be needed. The rules allow you to only copy what you need.   
  
 I think we need to take a look at what to do when $Source.Repo$ is referenced when there are no matching rules, it really should throw and exception because otherwise you get the behavior you were seeing, which is neither as desired or particularly useful.

---

<div class="post-metadata">

### Author: ![skermajo](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/s/bb73d2/32.png) [@skermajo](https://www.finalbuilder.com/forums/u/skermajo)
#### Post date: [October 2, 2012, 4:55am UTC](https://www.finalbuilder.com/forums/t/create-directory-run-dos-command-source-path-expansion/5747/8 "2012-10-02T04:55:29Z")

</div>

Thanks Vincent! Now that I understand that concept, I realise I've been ordering things incorrectly. I've been doing all my source copies in the first stage, regardless of what stage I actually need them - I guess I incorrectly&nbsp;surmised&nbsp;from $Source$\>$Source$ default rule what I should be doing, and didn't stop to think about it (and there really isn't another option for the default rule).

Your way makes much more sense, and it's a lot easier to manage the build stages

---

<div class="post-metadata">

### Author: ![skermajo](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/s/bb73d2/32.png) [@skermajo](https://www.finalbuilder.com/forums/u/skermajo)
#### Post date: [October 2, 2012, 6:15am UTC](https://www.finalbuilder.com/forums/t/create-directory-run-dos-command-source-path-expansion/5747/9 "2012-10-02T06:15:05Z")

</div>

Following the rule that each stage should be&nbsp;responsible&nbsp;for it's own repo copying (roughly), it looks like the following is not enough to get a valid $Source.MyRepo$ variable:

$Source.MyRepo$\foo\*\*.bar \> Source\MyRepo

Attempting to use $Source.MyRepo$ in a stage with only this rule results in an empty string. You seem to need the following to get the desired files and a valid $Source.MyRepo$ variable:

$Source.MyRepo$ \> Source\MyRepo  
-$Source.MyRepo$\anotherfoo\*\* \> Source\MyRepo  
- { numerous other directory/file exclusions }

or

$Source$ \> Source  
-$Source.MyRepo$ \> Source\MyRepo  
-$Source.AnotherRepo$ \> Source\AnotherRepo  
- { other repo exclusions here }  
$Source.MyRepo$\foo\*\*.bar \> Source\MyRepo

This exclusion stuff gets pretty tricky to maintain. I may have missed something again, but shouldn't the first example be enough to get a valid $Source.MyRepo$ variable value without having to resort to an entire repo copy coupled with exclusions?

I tried to be clever and do something like:

$Source.MyRepo$ \> Source\MyRepo  
-$Source.MyRepo$ \> Source\MyRepo  
$Source.MyRepo$\foo\*\*.bar \> Source\MyRepo

That gave my a valid $Source.MyRepo$ variable, but nothing in the folder for obvious reasons

---

<div class="post-metadata">

### Author: ![Vincent](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/vincent/32/938_2.png) [@Vincent](https://www.finalbuilder.com/forums/u/Vincent)
#### Post date: [October 2, 2012, 7:20am UTC](https://www.finalbuilder.com/forums/t/create-directory-run-dos-command-source-path-expansion/5747/10 "2012-10-02T07:20:53Z")

</div>

Hi Joel   
  
 Vinnie just pointed me to the doco (lol!) : [http://wiki.finalbuilder.com/display/continua/Repository+Rules](http://wiki.finalbuilder.com/display/continua/Repository+Rules)  
  
 When copying part of a repository, there is no way to infer the path that $Source.MyRepo$ points to, with this rule :   
  
 $Source.MyRepo$\foo\*_.bar \> Source\MyRepo_   
  
 _Where would you expect $Source.MyRepo$ to point to? Then there may also be other rules which further complicate things:_   
  
 _$Source.MyRepo$\foo\*_.bar \> Source\MyRepo   
 $Source.MyRepo$\bar\*\*.foo \> Source\Fooey   
  
 The solution is to not use $Source.MyRepo$ in the actions, just use the path you have in your rules, ie \Source\MyRepo - this will be relative to the root of the build workspace. The down side to that is it’s sort of ‘hard coded’. We’re looking into whether we can expand variables in the rules… can’t promise that will be possible, but that might make it a bit less hard coded then.

---

<div class="post-metadata">

### Author: ![skermajo](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/s/bb73d2/32.png) [@skermajo](https://www.finalbuilder.com/forums/u/skermajo)
#### Post date: [October 2, 2012, 8:25am UTC](https://www.finalbuilder.com/forums/t/create-directory-run-dos-command-source-path-expansion/5747/11 "2012-10-02T08:25:52Z")

</div>

That makes a lot of sense. Thanks for bearing with me guys.

---

<div class="post-metadata">

### Author: ![skermajo](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/s/bb73d2/32.png) [@skermajo](https://www.finalbuilder.com/forums/u/skermajo)
#### Post date: [October 2, 2012, 12:11pm UTC](https://www.finalbuilder.com/forums/t/create-directory-run-dos-command-source-path-expansion/5747/12 "2012-10-02T12:11:01Z")

</div>

I guess you could always write the path to a variable as well to avoid the hard coding.

---

<div class="post-metadata">

### Author: ![Vincent](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/vincent/32/938_2.png) [@Vincent](https://www.finalbuilder.com/forums/u/Vincent)
#### Post date: [October 2, 2012, 12:44pm UTC](https://www.finalbuilder.com/forums/t/create-directory-run-dos-command-source-path-expansion/5747/13 "2012-10-02T12:44:41Z")

</div>

Well the good news is that Vinnie got variables working in the rules just before we left for the day, needs a bit of tidying up but should be in tomorrow’s build.
