Ian Kirkpatrick
Ian Kirkpatrick

Reputation: 1960

MSBuild Unhandled Exception: The FileName property should not be a directory unless UseShellExecute is set

Versions

Problem

I am running a ASP.NET Core project in docker. When I docker-compose up, I get the following:

Unhandled Exception: Microsoft.Build.BackEnd.NodeFailedToLaunchException: The FileName property should not be a directory unless UseShellExecute is set. ---> System.ComponentModel.Win32Exception: The FileName property should not be a directory unless UseShellExecute is set.
   at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start()
   at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
   at Microsoft.Build.BackEnd.NodeProviderOutOfProcBase.LaunchNode(String msbuildLocation, String commandLineArgs)
   --- End of inner exception stack trace ---
   at Microsoft.Build.CommandLine.MSBuildApp.BuildProject(String projectFile, String[] targets, String toolsVersion, Dictionary`2 globalProperties, Dictionary`2 restoreProperties, ILogger[] loggers, LoggerVerbosity verbosity, DistributedLoggerRecord[] distributedLoggerRecords, Int32 cpuCount, Boolean enableNodeReuse, TextWriter preprocessWriter, Boolean detailedSummary, ISet`1 warningsAsErrors, ISet`1 warningsAsMessages, Boolean enableRestore, ProfilerLogger profilerLogger, Boolean enableProfiler)
   at Microsoft.Build.CommandLine.MSBuildApp.Execute(String[] commandLine)
   at Microsoft.Build.CommandLine.MSBuildApp.Main(String[] args)

The error seems to occur when it hits the dotnet restore line in the dockerfile.

After checking for permissions, it seems that docker has read/write permissions to all the files/folders directly involved

There were some updates this morning that others on this post have said they also had. Whether they were the same updates is unknown. But there were a couple updates. Here is my update log from the morning that this all started happening.

My Dockerfile is like so:

FROM microsoft/dotnet:2.1.403-sdk as dotnet

WORKDIR /vsdbg

RUN apt-get update \
    && apt-get install -y --no-install-recommends \
      unzip \
    && rm -rf /var/lib/apt/lists/* \
    && curl -sSL https://aka.ms/getvsdbgsh | bash /dev/stdin -v latest -l /vsdbg

WORKDIR /ProjA

# Install TRX -> JUnit log file converter
# https://github.com/gfoidl/trx2junit
RUN dotnet tool install -g trx2junit
RUN export PATH="$PATH:/root/.dotnet/tools"

COPY ProjA.sln .
COPY ProjA/ProjA.csproj ./ProjA/
COPY ProjA.Tests/ProjA.Tests.csproj ./ProjA.Tests/
COPY ProjB/ProjB.csproj ./ProjB/
COPY ProjC/ProjC.csproj ./ProjC/

RUN mkdir ProjA.Tests/tmp

RUN dotnet restore # ******* Error seems to happen here...

COPY . .

WORKDIR /ProjA/ProjA/

CMD ["dotnet", "run"]

Upvotes: 27

Views: 3636

Answers (9)

fatihyildizhan
fatihyildizhan

Reputation: 8832

The simplest solution is for .Net Core 2.1 and 2.2 is using lower Ubuntu version.

on: [push]

jobs:

  build:

    runs-on: ubuntu-16.04

    steps:
    - uses: actions/checkout@v1
    - name: Build the Docker image
      run: docker build . --file Dockerfile --tag yourtagname:$(date +%s)

Upvotes: 3

jcmordan
jcmordan

Reputation: 1048

I had the same issue on ubuntu 9.04. I made the downgrade to linux-generic=5.0.0.13.14 and it's working now!

Just run the following command :

sudo apt install linux-image-generic=5.0.0.13.14 linux-headers-generic=5.0.0.13.14 linux-generic=5.0.0.13.14

Then restart using "Ubuntu Advanced options" and then choose the linux-generic_5.0.0.13.14opton.

Upvotes: 0

Jakob Heine
Jakob Heine

Reputation: 120

I ran into the same issue and downgrading the linux kernel from 5.0.0-27-generic to 5.0.0.-25-generic fixed it.

A simple way to downgrade the linux kernel is to use the package Uku, which license costs 12$.

The free alternative is described here.

Another possibility is to increase the GRUB Timeout and choose the desired kernel version in the boot menu on every system start manually, which is described here.

Upvotes: 6

MiguelJm
MiguelJm

Reputation: 1

Solutions


apt-add-repository -y ppa:teejee2008/ppa
apt-get update
apt-get install ukuu
ukuu --install-latest
reboot
uname -sr

Upvotes: 0

John Sloper
John Sloper

Reputation: 1821

This bug has been confirmed on Ubuntu: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1843018

Relevant .net Core issue: https://github.com/dotnet/corefx/issues/40850

Upvotes: 0

dturan
dturan

Reputation: 66

I have been struggling with the same problem since yesterday, but the problem stems from ubuntun, because I created and worked without problems from kali linux, but I continued to receive errors despite my attempts at 18.04 and 19.04.

Docker version

Version:           19.03.2
 API version:       1.40
 Go version:        go1.12.8
 Git commit:        6a30dfc
 Built:             Thu Aug 29 05:29:11 2019
 OS/Arch:           linux/amd64
 Experimental:      false

Dockerfile

FROM microsoft/dotnet:2.1-sdk AS build
COPY . project/
WORKDIR /project
run dotnet restore dotnet.sln 

FROM build AS publish
WORKDIR /Project/
RUN dotnet publish dotnet.sln -c Release -o /app

FROM microsoft/dotnet:2.1-aspnetcore-runtime AS runtime
COPY . Project/
WORKDIR /app
EXPOSE 8003

FROM runtime AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "dotnet.dll"]

Upvotes: 0

Lubos Voska
Lubos Voska

Reputation: 177

Same problem here. Update Ubuntu kernel to last version (5.0.0-27-generic) solve the problem.

Upvotes: 2

Alan Thomas
Alan Thomas

Reputation: 121

We run Ubuntu 18.04 on Azure as our Docker hosts. Azure recently pushed out kernel version 5.0.0-1018, which caused the issue in our Linux containers. Downgrading to kernel version 4.18.0-1025 fixed it for us.

Upvotes: 12

1mikevdm
1mikevdm

Reputation: 11

I ran into the same problem today, with docker files that were working fine for months. There were some repos that worked, but others simply didn't. Without ANY changes. Docker files failed to run and got this same error "MSBuild Unhandled Exception: The FileName property should not be a directory unless UseShellExecute is set". I was originally using docker 18.09.7 and upgraded to 19.3.2, but that didn't help.

I was running Ubuntu 18.04.3 and had noticed some updates installing in the morning. This is a simple build system, with very little installed (VS Code, Gitkraken, docker, docker-compose)

Since some of my builds were failing and I couldn't find a culprit, I reinstalled and downgraded to Ubuntu 18.04.2 and reinstalled the few things I need to build. And everything was working again. I suspect the updates in the morning broke things. Unfortunately I didn't keep the upgrade log :-(

Upvotes: 1

Related Questions