Skip to content

Process.Start() doesn't work in netcoreapp2.1 but good in 2.0 #1857

Description

@LincolnYang1

Process.Start() doesn't work in netcoreapp2.1 but good in 2.0

i have below simple code to demo the issue, it works well in netcoreapp2.0 but not in netcoreapp2.1
system is aws cloud,
Linux version 4.9.81-35.56.amzn1.x86_64 (mockbuild@gobi-build-64010) (gcc version 7.2.1 20170915 (Red Hat 7.2.1-2) (GCC) ) #1 SMP Fri Feb 16 00:18:48 UTC 2018

        static void Main(string[] args)
        {
            var fileName = args[0];
            Console.WriteLine($"{fileName} : exists: {File.Exists(fileName)}");
            
            var processStartInfo = new ProcessStartInfo(fileName)
            {
                Arguments = "--info",
                UseShellExecute = true
            };
            var process = Process.Start(processStartInfo) ?? throw new Exception("failed to start process");
            process.WaitForExit();
        }

run-time parameter is, /opt/dotnet/dotnet is the dotnet executable path
dotnet testapp.dll /opt/dotnet/dotnet

project file is

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.0</TargetFramework>
    <RuntimeIdentifiers>rhel.7.4-x64</RuntimeIdentifiers>
  </PropertyGroup>
</Project>

Build and Publish

if change project to 2.0, build and publish with dotnet core 2.0, it works fine.

dotnet build --runtime rhel.7.4-x64
dotnet publish --runtime rhel.7.4-x64 -c Release --framework netcoreapp2.0

but if change to 2.1
dotnet build --runtime rhel.7.4-x64
dotnet publish --runtime rhel.7.4-x64 -c Release --framework netcoreapp2.1

it throw error, there is Win32Exception throw out.

Unhandled Exception: System.ComponentModel.Win32Exception: No such file or directory
at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start()
at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
at testapp.Program.Main(String[] args) in source\repos\testapp\testapp\Program.cs:line 14

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions