# Invoking an NMAKE build

**URL:** <https://travis-ci.community/t/invoking-an-nmake-build/13505>\
**Category:** Windows\
**Created:** [January 6, 2023, 9:46am UTC](https://travis-ci.community/t/invoking-an-nmake-build/13505 "2023-01-06T09:46:40Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![rptb1](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/rptb1/32/8425_2.png) [@rptb1](https://travis-ci.community/u/rptb1)\
**Post date:** [January 6, 2023, 9:46am UTC](https://travis-ci.community/t/invoking-an-nmake-build/13505/1 "2023-01-06T09:46:40Z")

</div>

I’m trying to automate our build on Windows. Our requirement is to validate changes for the target platform combination: Windows + Visual Studio tools, so it’s no good using GCC or Clang for this. We specifically need to check compilation with Microsoft’s compiler, and indeed NMAKE.

So I’m trying to invoke CMD.EXE to run our make using Visual Studio tools. But I can’t seem to get a literal string through to CMD. Here is what I’m trying:

`MSYS2_ARG_CONV_EXCL="*" cmd /k '"C:\Program Files (x86)\Microsoft Visual Studio 2017\BuildTools\Common7\Tools\VsDevCmd.bat" && cd code && nmake'`

But what I get back is an error from CMD like:

`'\"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\Tools\VsDevCmd.bat\"' is not recognized...`

So you see something is inserting extra backslash escapes into the string I want to pass to CMD. This alone works:

`MSYS2_ARG_CONV_EXCL="*" cmd /k 'C:\Program Files (x86)\Microsoft Visual Studio 2017\BuildTools\Common7\Tools\VsDevCmd.bat'`

but of course it does not kick off the build.

What’s going on here? Suggestions?

References:

- I’m attempting to automate [mps/build.txt at master · Ravenbrook/mps · GitHub](https://github.com/Ravenbrook/mps/blob/master/manual/build.txt)
- I’ve seen [NMake support from Windows](https://travis-ci.community/t/nmake-support-from-windows/1079)

If any Travis CI folks read this: we want CMD (or maybe Powershell) and the Microsoft compilers to be first-class! We need to build using Visual Studio. Thanks!

---

<div class="post-metadata">

**Author:** ![tanzislam](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/tanzislam/32/2591_2.png) [@tanzislam](https://travis-ci.community/u/tanzislam)\
**Post date:** [January 6, 2023, 1:58pm UTC](https://travis-ci.community/t/invoking-an-nmake-build/13505/2 "2023-01-06T13:58:11Z")

</div>

Try:  
`MSYS2_ARG_CONV_EXCL="*" cmd /k 'C:\Program Files (x86)\Microsoft Visual Studio 2017\BuildTools\Common7\Tools\VsDevCmd.bat & cd code & nmake'`

Basically invoke `nmake` in the same `cmd.exe` environment that you ran `VsDevCmd.bat` in.

---

<div class="post-metadata">

**Author:** ![rptb1](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/rptb1/32/8425_2.png) [@rptb1](https://travis-ci.community/u/rptb1)\
**Post date:** [January 6, 2023, 2:58pm UTC](https://travis-ci.community/t/invoking-an-nmake-build/13505/3 "2023-01-06T14:58:31Z")

</div>

> [@tanzislam](#):
>
> MSYS2\_ARG\_CONV\_EXCL=“\*” cmd /k ‘C:\Program Files (x86)\Microsoft Visual Studio 2017\BuildTools\Common7\Tools\VsDevCmd.bat & cd code & nmake’

Thanks, but that is how I started, and it fails with CMD saying: ‘C:\Program’ is not recognized.

I have solved this problem in a different way and will post details soon for other people.

---

<div class="post-metadata">

**Author:** ![rptb1](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/rptb1/32/8425_2.png) [@rptb1](https://travis-ci.community/u/rptb1)\
**Post date:** [January 6, 2023, 3:13pm UTC](https://travis-ci.community/t/invoking-an-nmake-build/13505/4 "2023-01-06T15:13:31Z")

</div>

I have solved this problem by creating an auxiliary BAT script, so avoiding all the quoting madness between MSYS2, Bash, and CMD.

The script is in [code/w3i6mv.bat](https://github.com/Ravenbrook/mps/blob/e78c6e16735d7f16ef86a7f2f8356791a18c8a6e/code/w3i6mv.bat):

```auto
@rem w3i6mv.bat -- set up and invoke build from raw CMD on Windows
@rem This can be invoked from a plain CMD from the MPS workspace
@rem like this::
@rem code\w3i6mv.bat
@rem or from Git Bash in Travis CI build machines like this::
@rem MSYS2_ARG_CONV_EXCL='*' cmd /k 'code\w3i6mv.bat'
@rem which is how it's invoked from .travis.yml
call "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" x64
cd code
nmake /f w3i6mv.nmk

```

and it’s [invoked from .travis.yml like this](https://github.com/Ravenbrook/mps/blob/e78c6e16735d7f16ef86a7f2f8356791a18c8a6e/.travis.yml#L16-L20):

```auto
  include:
    - os: windows
      arch: amd64
      compiler: clang # This is a lie since we invoke MV (Microsoft C)
      script: MSYS2_ARG_CONV_EXCL='*' cmd /c 'code\w3i6mv.bat'

```

So we have to lie to Travis CI about the toolchain, which is a shame, but this is only a few lines of extra stuff, so it keeps Travis integration lightweight, which is what we need.

---

<div class="post-metadata">

**Author:** ![Montana](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/montana/32/9566_2.png) [@Montana](https://travis-ci.community/u/Montana)\
**Post date:** [January 6, 2023, 11:52pm UTC](https://travis-ci.community/t/invoking-an-nmake-build/13505/5 "2023-01-06T23:52:31Z")

</div>

Hi @rptb1,

As stated, probably the best way:

```bash
MSYS2_ARG_CONV_EXCL="*" cmd /c call <path\to\bat> \&\& nmake

```

---

<div class="post-metadata">

**Author:** ![rptb1](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/rptb1/32/8425_2.png) [@rptb1](https://travis-ci.community/u/rptb1)\
**Post date:** [January 7, 2023, 4:20am UTC](https://travis-ci.community/t/invoking-an-nmake-build/13505/6 "2023-01-07T04:20:07Z")

</div>

> [@Montana](#):
>
> `MSYS2_ARG_CONV_EXCL="*" cmd /c call <path\to\bat> \&\& nmake`

Just for the benefit of other readers, this doesn’t work either.
