Skip to content

build.cmd fails if path contains a space #42397

Open

Description

@verdie-g

My username is abc def and I get an error running build.cmd.

PS> .\build.cmd
  Determining projects to restore...
  Tool 'coverlet.console' (version '1.7.2') was restored. Available commands: coverlet
  Tool 'dotnet-reportgenerator-globaltool' (version '4.5.8') was restored. Available commands: reportgenerator
  Tool 'microsoft.dotnet.xharness.cli' (version '1.0.0-prerelease.20403.2') was restored. Available commands: xharness

  Restore was successful.
  All projects are up-to-date for restore.
  Determining projects to restore...
  All projects are up-to-date for restore.
  Determining projects to restore...
  All projects are up-to-date for restore.
  Determining projects to restore...
  All projects are up-to-date for restore.
  Determining projects to restore...
  All projects are up-to-date for restore.
  Determining projects to restore...
  All projects are up-to-date for restore.
  Determining projects to restore...
  All projects are up-to-date for restore.
  Determining projects to restore...
  Restored C:\Users\abc def\Documents\dotnet-runtime\src\installer\pkg\projects\netcoreapp\pkg\legacy\Microsoft.NETCore.App.pkgproj (in 162 ms).
  1 of 2 projects are up-to-date for restore.
  Determining projects to restore...
  All projects are up-to-date for restore.
  Determining projects to restore...
  All projects are up-to-date for restore.
  Determining projects to restore...
  All projects are up-to-date for restore.
  Determining projects to restore...
  All projects are up-to-date for restore.
  Determining projects to restore...
  Restored C:\Users\abc def\Documents\dotnet-runtime\src\installer\pkg\projects\netcoreapp\pkg\workaround\Microsoft.NETCore.App.pkgproj (in 43 ms).
  Determining projects to restore...
  All projects are up-to-date for restore.
  Determining projects to restore...
  All projects are up-to-date for restore.
  System.Private.CoreLib -> C:\Users\abc def\Documents\dotnet-runtime\artifacts\bin\coreclr\Windows_NT.x64.Debug\IL\System.Private.CoreLib.dll
  BUILD: Starting Build at 20:07:06.52
  '""C:\Users\abc' is not recognized as an internal or external command,
  operable program or batch file.
C:\Users\abc def\Documents\dotnet-runtime\src\coreclr\runtime.proj(37,5): error MSB3073: The command ""C:\Users\abc def\Documents\dotnet-runtime\src\coreclr\build-runtime.cmd" -x64 -debug" exited with code 1.

Build FAILED.

C:\Users\abc def\Documents\dotnet-runtime\src\coreclr\runtime.proj(37,5): error MSB3073: The command ""C:\Users\abc def\Documents\dotnet-runtime\src\coreclr\build-runtime.cmd" -x64 -debug" exited with code 1.
    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:50.88
Build failed.
Some builds failed:
        Configuration: Debug, Architecture: x64

After removing the line @if not defined _echo @echo off in build-runtime.cmd and running the file I get the same error but with more details.

PS C:\Users\abc def\Documents\dotnet-runtime2> .\src\coreclr\build-runtime.cmd -x64 -release -enforcegpo
C:\Users\abc def\Documents\dotnet-runtime2>setlocal EnableDelayedExpansion EnableExtensions
C:\Users\abc def\Documents\dotnet-runtime2>set "__MsgPrefix=BUILD: "
C:\Users\abc def\Documents\dotnet-runtime2>echo BUILD: Starting Build at 20:11:03.01
BUILD: Starting Build at 20:11:03.01
C:\Users\abc def\Documents\dotnet-runtime2>set __ThisScriptFull="C:\Users\abc def\Documents\dotnet-runtime2\src\coreclr\build-runtime.cmd"
C:\Users\abc def\Documents\dotnet-runtime2>set __ThisScriptDir="C:\Users\abc def\Documents\dotnet-runtime2\src\coreclr\"
C:\Users\abc def\Documents\dotnet-runtime2>call ""C:\Users\abc def\Documents\dotnet-runtime2\src\coreclr\""\setup_vs_tools.cmd
'""C:\Users\abc' is not recognized as an internal or external command,
operable program or batch file.
C:\Users\abc def\Documents\dotnet-runtime2>if NOT '1' == '0' goto ExitWithError
C:\Users\abc def\Documents\dotnet-runtime2>exit /b 1

It seems like there is an issue with quotes at the line call ""C:\Users\abc def\Documents\dotnet-runtime2\src\coreclr\""\setup_vs_tools.cmd.

Activity

  1. danmoseley commented on Sep 17, 2020

    @danmoseley
    Contributor

    I think these

    set __ThisScriptFull="%~f0"
    set __ThisScriptDir="%~dp0"

    should probably not add quotes and instead the quotes should be applied where they are used
    call "%__ThisScriptDir%"\setup_vs_tools.cmd

    may help to copy its "DIA SDK" folder into "%VSINSTALLDIR%" manually, then try again.

    Same in crossgen-corelib.cmd.

    Can you try that and see how it works?

    Building the repo when there's a space in the path breaks periodically because we dont have a test to protect it and apparently nobody that works on the repo day to day has this configuration.

  2. verdie-g commented on Sep 17, 2020

    @verdie-g
    ContributorAuthor

    Adding some quotes at the right place allowed to execute few more lines without errors until the same issue happened again. I think quotes are missing at many places in the scripts and I don't feel comfortable doing the PR. It should be easy to reproduce by adding a space in the project folder though.

  3. danmoseley commented on Sep 17, 2020

    @danmoseley
    Contributor

    Too bad thanks for trying. Realistically this is going to keep breaking regularly and probably not a high priority. Can you place the repo another location?

  4. verdie-g commented on Sep 17, 2020

    @verdie-g
    ContributorAuthor

    Building the repo when there's a space in the path breaks periodically because we dont have a test to protect it

    this is going to keep breaking regularly

    Is having a test with a space in the path not possible?

    Can you place the repo another location?

    I have the student version of Windows 10 which forces $"{firstName} {lastName}" as a username so I'll move the folder to C: or maybe it's time to get a real license 👍

  5. danmoseley commented on Sep 17, 2020

    @danmoseley
    Contributor

    We could modify one of our CI legs potentially (cc @safern) but it's probably not a priority because the workaround is pretty easy. I put my repo for example in C:\git\runtime

  6. verdie-g commented on Sep 18, 2020

    @verdie-g
    ContributorAuthor

    the workaround is pretty easy. I put my repo for example in C:\git\runtime

    After putting the repository in C:\dev\dotnet-runtime I get the same error. It seems like it's searching for files under my user folder.

    CROSSGEN-CORELIB: Starting Build at 20:36:04.41
      CROSSGEN-CORELIB: Searching for Visual Studio installation
      CROSSGEN-CORELIB: "C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\Common7\Tools\VsDevCmd.bat"
      **********************************************************************
      ** Visual Studio 2019 Developer Command Prompt v16.8.0-pre.3.0
      ** Copyright (c) 2020 Microsoft Corporation
      **********************************************************************
      CROSSGEN-CORELIB: Using environment: "C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\Common7\Tools\\..\..\VC\Auxiliary\Build\vcvarsall.bat" x86_amd64
      **********************************************************************
      ** Visual Studio 2019 Developer Command Prompt v16.8.0-pre.3.0
      ** Copyright (c) 2020 Microsoft Corporation
      **********************************************************************
      [vcvarsall.bat] Environment initialized for: 'x86_x64'
      CROSSGEN-CORELIB: Generating native image of System.Private.CoreLib for Windows_NT.x64.Release. Logging to "C:\Dev\dotnet-runtime\src\coreclr\..\..\artifacts\log\CrossgenCoreLib_Windows_NT__x64__Release.log".
      "C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Roslyn\Microsoft.DiaSymReader.Native.amd64.dll"
      "C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\Common7\IDE\Microsoft.DiaSymReader.Native.amd64.dll"
      CROSSGEN-CORELIB: "C:\Dev\dotnet-runtime\src\coreclr\..\..\artifacts\bin\coreclr\Windows_NT.x64.Release\crossgen.exe" /nologo  /Platform_Assemblies_Paths "C:\Dev\dotnet-runtime\src\coreclr\..\..\artifacts\bin\coreclr\Windows_NT.x64.Release\IL" /out "C:\Dev\dotnet-runtime\src\coreclr\..\..\artifacts\bin\coreclr\Windows_NT.x64.Release\System.Private.CoreLib.dll" "C:\Dev\dotnet-runtime\src\coreclr\..\..\artifacts\bin\coreclr\Windows_NT.x64.Release\IL\System.Private.CoreLib.dll"
      CROSSGEN-CORELIB: "C:\Dev\dotnet-runtime\src\coreclr\..\..\artifacts\bin\coreclr\Windows_NT.x64.Release\crossgen.exe" /nologo /Platform_Assemblies_Paths "C:\Dev\dotnet-runtime\src\coreclr\..\..\artifacts\bin\coreclr\Windows_NT.x64.Release" /CreatePdb "C:\Dev\dotnet-runtime\src\coreclr\..\..\artifacts\bin\coreclr\Windows_NT.x64.Release\PDB" "C:\Dev\dotnet-runtime\src\coreclr\..\..\artifacts\bin\coreclr\Windows_NT.x64.Release\System.Private.CoreLib.dll"
      CROSSGEN-CORELIB: Crossgenning of System.Private.CoreLib succeeded.  Finished at 20:36:13.13
      CROSSGEN-CORELIB: Product binaries are available at C:\Dev\dotnet-runtime\src\coreclr\..\..\artifacts\bin\coreclr\Windows_NT.x64.Release
      ILCompiler.DependencyAnalysisFramework -> C:\Dev\dotnet-runtime\artifacts\bin\ILCompiler.DependencyAnalysisFramework\x64\Release\ILCompiler.DependencyAnalysisFramework.dll
      ILCompiler.TypeSystem.ReadyToRun -> C:\Dev\dotnet-runtime\artifacts\bin\ILCompiler.TypeSystem.ReadyToRun\x64\Release\ILCompiler.TypeSystem.ReadyToRun.dll
      ILCompiler.ReadyToRun -> C:\Dev\dotnet-runtime\artifacts\bin\ILCompiler.ReadyToRun\x64\Release\ILCompiler.ReadyToRun.dll
      crossgen2 -> C:\Dev\dotnet-runtime\artifacts\bin\coreclr\Windows_NT.x64.Release\crossgen2\crossgen2.dll
      CoreTestAssembly -> C:\Dev\dotnet-runtime\artifacts\bin\CoreTestAssembly\x64\Release\CoreTestAssembly.dll
      'C:\Users\abc' is not recognized as an internal or external command,
      operable program or batch file.
    C:\Users\abc def\.nuget\packages\microsoft.net.sdk.il\5.0.0-preview.8.20359.4\targets\Microsoft.NET.Sdk.IL.targets(138,5): error MSB3073: The command "C:\Users\abc def\.nuget\packages\\runtime.win-x64.microsoft.netcore.ilasm\5.0.0-preview.8.20359.4\runtimes\win-x64\native/ilasm -QUIET -NOLOGO -OPTIMIZE -DLL  -OUTPUT="C:\Dev\dotnet-runtime\artifacts\obj\coreclr\ILTestAssembly\x64\Release\ILTestAssembly.dll"  Main.il ILDisassembler.il InstanceFieldLayout.il StaticFieldLayout.il VirtualFunctionOverride.il Signature.il MethodImplOverride1.il" exited with code 9009. [C:\Dev\dotnet-runtime\src\coreclr\src\tools\aot\ILCompiler.TypeSystem.ReadyToRun.Tests\ILTestAssembly\ILTestAssembly.ilproj]
    
    Build FAILED.
    
    C:\Users\abc def\.nuget\packages\microsoft.net.sdk.il\5.0.0-preview.8.20359.4\targets\Microsoft.NET.Sdk.IL.targets(138,5): error MSB3073: The command "C:\Users\abc def\.nuget\packages\\runtime.win-x64.microsoft.netcore.ilasm\5.0.0-preview.8.20359.4\runtimes\win-x64\native/ilasm -QUIET -NOLOGO -OPTIMIZE -DLL  -OUTPUT="C:\Dev\dotnet-runtime\artifacts\obj\coreclr\ILTestAssembly\x64\Release\ILTestAssembly.dll"  Main.il ILDisassembler.il InstanceFieldLayout.il StaticFieldLayout.il VirtualFunctionOverride.il Signature.il MethodImplOverride1.il" exited with code 9009. [C:\Dev\dotnet-runtime\src\coreclr\src\tools\aot\ILCompiler.TypeSystem.ReadyToRun.Tests\ILTestAssembly\ILTestAssembly.ilproj]
        0 Warning(s)
        1 Error(s)
    
    Time Elapsed 00:10:32.52
    Build failed.
    Some builds failed:
            Configuration: Debug, Architecture: x64
    
  7. safern commented on Sep 22, 2020

    @safern
    Member

    It seems like we need to add quotes to usages of _ILasmDir:

    <Exec Command="$(_IlasmDir)ilasm $(_IlasmSwitches) $(_OutputTypeArgument) $(IlasmFlags) -OUTPUT=&quot;@(IntermediateAssembly)&quot; $(_KeyFileArgument) @(Compile, ' ')">

    and also to usages of _ILdasmDir:

    <_IldasmCommand>$(_IldasmDir)ildasm</_IldasmCommand>

  8. added this to the 6.0.0 milestone on Sep 22, 2020
  9. removed
    untriagedNew issue has not been triaged by the area owner
    on Sep 22, 2020
  10. trylek commented on Sep 22, 2020

    @trylek
    Member

    I suspect this will blow up in multiple places in the scripts as we're generally not too consistent about quoting everything. I'm adding this to the infra backlog project as it definitely merits fixing, it's just likely to have quite a bit of a bug tail.

  11. mangod9 commented on Sep 24, 2020

    @mangod9
    Member

    I have a partial fix I am validating here: #42671.

    C:\With Space\runtime>build -subset clr+libs should now work if the targets fix is manually applied.

  12. danmoseley commented on Sep 24, 2020

    @danmoseley
    Contributor

    I suspect this will blow up in multiple places in the scripts as we're generally not too consistent about quoting everything

    This has come up and been fixed again a number of times. I suggest to either protect the next fix with CI or just document it doesn't work.

  13. 16 remaining items

  14. mangod9 commented on Sep 28, 2020

    @mangod9
    Member

    keeping this open so we can track the CI changes to ensure this doesnt regress, but that will have to wait for the il.targets to propagate to sdk and back.

  15. lkempf commented on Nov 11, 2020

    @lkempf

    I have found a regression of this issue. Executing ./build.cmd -subset clr -ninja fails when the build path contains spaces as of commit e8bba0b. This is caused by missing quotes in build-runtime.cmd around %__IntermediatesDir%.

    There also is a problem with generating timestamps which I have not been able to pinpoint yet.

      FAILED: src/dlls/mscoree/coreclr/inject_debug_resources.timestamp
      src\dlls\mscoree\coreclr\CMakeFiles\inject_debug_resources.timestamp-7773978.bat 645c5eb38508e330
      Microsoft (R) C/C++ Optimizing Compiler Version 19.28.29333 for x64
      Copyright (C) Microsoft Corporation.  All rights reserved.
    
      daccess.cpp
      'C:\Users\bla\Documents\Visual' is not recognized as an internal or external command,
      operable program or batch file.
      Batch file failed at line 4 with errorcode 1
      ninja: build stopped: subcommand failed.
    
  16. mangod9 commented on Nov 11, 2020

    @mangod9
    Member

    Hey @lkempf, thanks for reporting the issue. Would you like to submit a PR, assuming its a simple fix? Else will take a look later this week, we also plan to add verification for this within the CI.

  17. trylek commented on Nov 11, 2020

    @trylek
    Member
  18. lkempf commented on Nov 11, 2020

    @lkempf

    I've created #44540 to fix the issue I could pinpoint.

  19. modified the milestones: 6.0.0, Future on May 5, 2021
  20. ViktorHofer commented on May 5, 2021

    @ViktorHofer
    Member

    @mangod9 as you are assigned to the issue, do you know what's remaining here? CI protection or an infra fix?

  21. mangod9 commented on May 5, 2021

    @mangod9
    Member

    primarily CI protection, I had a fix made a few months ago, but there is a good possibility things have since regressed.

  22. ivdiazsa commented on Aug 24, 2022

    @ivdiazsa
    Contributor

    This is still a thing in as noted in #73327. I wrote a deeper explanation here #73327 (comment).

  23. dotnet-policy-service commented on Apr 13, 2026

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @dotnet/runtime-infrastructure
    See info in area-owners.md if you want to be subscribed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions