Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c#

docker

asp.net

Versions

  • dotnet core sdk: 2.1.403
  • docker: 18.09.7
  • Linux Kernel: 5.0.0-27
  • Ubuntu: 18.04.3

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"]
like image 445
Ian Kirkpatrick Avatar asked Sep 04 '19 14:09

Ian Kirkpatrick


2 Answers

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.

like image 95
Alan Thomas Avatar answered Oct 20 '22 04:10

Alan Thomas


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.

like image 6
Jakob Heine Avatar answered Oct 20 '22 03:10

Jakob Heine