dotnet/msbuild

Exec Command UseCommandProcessor = "True" is missing cmd.exe

Open

#5,451 创建于 2020年6月21日

在 GitHub 查看
 (8 评论) (0 反应) (0 负责人)C# (1,364 fork)batch import
Area: Tasksbughelp wantedtriaged

仓库指标

Star
 (5,062 star)
PR 合并指标
 (平均合并 11天 7小时) (30 天内合并 125 个 PR)

描述

When setting UseCommandProcessor = "True" in an <exec .. task, the commandline switches /Q /D /C are generated, but the required cmd.exe is missing in the generated code.

Steps to reproduce

Open this project file in Visual Studio 2019 and build:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug' ">
    <OutputPath>bin\</OutputPath>
  </PropertyGroup>
  <PropertyGroup>
    <RootNamespace>VerilogIssue</RootNamespace>
    <ProjectGuid>{C32098DE-768D-4521-8C70-119A087D9407}</ProjectGuid>
  </PropertyGroup>
  <PropertyGroup>
    <InstallBuildDependenciesCmd>.\build\vs-prog.bat</InstallBuildDependenciesCmd>
    <PipelineDependsOn>
      InstallBuildDependencies;
    </PipelineDependsOn>
</PropertyGroup>

  <ItemGroup>
  </ItemGroup>
  <Target Name="Build">
    <Exec Command="ping 192.168.1.1" UseCommandProcessor = "True" YieldDuringToolExecution="True" ConsoleToMSBuild="true" Condition="'$(Configuration)'=='Debug' ">
      <Output TaskParameter="ConsoleOutput" ItemName="OutputOfExec" />
    </Exec> 
  </Target>
  <Target Name="Rebuild" DependsOnTargets="Clean;Build">
  </Target>
  <Target Name="Clean">
  </Target>
</Project>

Directory contents:

(none)

Expected behavior

As noted in the documentation, setting UseCommandProcessor = "true" should:

When set to true, this task creates a batch file for the command line and executes it by using the command-processor instead of executing the command directly.

First, no batch file is created... instead it appears there's an attempt to wrap with just cmd.exe.

Further, as shown in the example below, the cmd.exe is missing, and should should have been added like this:

cmd.exe /Q /D /C C:\Users\gojimmypi\AppData\Local\Temp\tmp8e500fe3f5f24fbd896f954d39d199f5.exec.cmd 

Actual behavior

Note in particular the 7th line:

1>  C:\Users\gojimmypi\source\repos\Verilog45\Verilog45>/Q /D /C ....

from the full build output:

1>------ Build started: Project: VerilogIssue, Configuration: Debug Any CPU ------
1>Build started 6/21/2020 11:41:07 AM.
1>Build:
1>  ping 192.168.1.1
1>  ping 192.168.1.1
1>  
1>  C:\Users\gojimmypi\source\repos\Verilog45\Verilog45>/Q /D /C C:\Users\gojimmypi\AppData\Local\Temp\tmp8e500fe3f5f24fbd896f954d39d199f5.exec.cmd 
1>  '/Q' is not recognized as an internal or external command,
1>  operable program or batch file.
1>C:\Users\gojimmypi\source\repos\Verilog45\Verilog45\VerilogIssue.csproj(20,5): error MSB3073: The command "ping 192.168.1.1" exited with code 1.
1>
1>Build FAILED.
1>
1>"C:\Users\gojimmypi\source\repos\Verilog45\Verilog45\VerilogIssue.csproj" (Build target) (1) ->
1>(Build target) -> 
1>  C:\Users\gojimmypi\source\repos\Verilog45\Verilog45\VerilogIssue.csproj(20,5): error MSB3073: The command "ping 192.168.1.1" exited with code 1.
1>
1>    0 Warning(s)
1>    1 Error(s)
1>
1>Time Elapsed 00:00:00.08
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Environment data

msbuild /version output:

C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise>msbuild /version
Microsoft (R) Build Engine version 16.5.0+d4cbfca49 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

16.5.0.12403

OS info:

Microsoft Windows [Version 10.0.18363.900]

If applicable, version of the tool that invokes MSBuild (Visual Studio, dotnet CLI, etc):

Microsoft Visual Studio Enterprise 2019 (3)
Version 16.6.1
VisualStudio.16.Release/16.6.1+30128.74
Microsoft .NET Framework
Version 4.8.03752

Installed Version: Enterprise

edit: this is related to https://github.com/gojimmypi/VerilogLanguageExtension/pull/25#issuecomment-640307560

贡献者指南