The Issue:
Perform the following steps to recreate the issue:
cd C:\Temp
New-Item -ItemType Directory -Name init-db-issue
cd .\init-db-issue
# Download ASP.NET Core sample projects
Invoke-WebRequest -Uri https://codeload.github.com/dotnet/AspNetCore.Docs/zip/main -OutFile main.zip
# Expanding takes a while
Expand-Archive -Path .\main.zip
cd .\main\AspNetCore.Docs-main\aspnetcore\security\authorization\secure-data\samples\final3
dotnet user-secrets set SeedUserPW Secret123!
# Drop the database in case it already exists
sqlcmd -S "(localdb)\MSSQLLocalDB" -Q "DROP DATABASE [aspnet-ContactManager-02]"
At this point, do not load the project in vs or vscode. Simply run the project from a PowerShell prompt:
dotnet run
Here's what I get on my system:
PS C:\Temp\init-db-issue\main\AspNetCore.Docs-main\aspnetcore\security\authorization\secure-data\samples\final3> dotnet run
C:\Program Files\dotnet\sdk\5.0.200\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.EolTargetFrameworks.targets(28,5): warning NETSDK1138: The target framework 'netcoreapp3.0' is out of support and will not receive security updates in the future. Please refer to https://aka.ms/dotnet-core-support for more information about the support policy. [C:\Temp\init-db-issue\main\AspNetCore.Docs-main\aspnetcore\security\authorization\secure-data\samples\final3\ContactManager.csproj]
C:\Program Files\dotnet\sdk\5.0.200\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.EolTargetFrameworks.targets(28,5): warning NETSDK1138: The target framework 'netcoreapp3.0' is out of support and will not receive security updates in the future. Please refer to https://aka.ms/dotnet-core-support for more information about the support policy. [C:\Temp\init-db-issue\main\AspNetCore.Docs-main\aspnetcore\security\authorization\secure-data\samples\final3\ContactManager.csproj]
C:\Program Files\dotnet\sdk\5.0.200\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.EolTargetFrameworks.targets(28,5): warning NETSDK1138: The target framework 'netcoreapp3.0' is out of support and will not receive security updates in the future. Please refer to https://aka.ms/dotnet-core-support for more information about the support policy. [C:\Temp\init-db-issue\main\AspNetCore.Docs-main\aspnetcore\security\authorization\secure-data\samples\final3\ContactManager.csproj]
fail: ContactManager.Program[0]
An error occurred seeding the DB.
System.AggregateException: One or more errors occurred. (Value cannot be null. (Parameter 'password'))
---> System.ArgumentNullException: Value cannot be null. (Parameter 'password')
at Microsoft.AspNetCore.Identity.UserManager`1.CreateAsync(TUser user, String password)
at ContactManager.Data.SeedData.EnsureUser(IServiceProvider serviceProvider, String testUserPw, String UserName) in C:\Temp\init-db-issue\main\AspNetCore.Docs-main\aspnetcore\security\authorization\secure-data\samples\final3\Data\SeedData.cs:line 49
at ContactManager.Data.SeedData.Initialize(IServiceProvider serviceProvider, String testUserPw) in C:\Temp\init-db-issue\main\AspNetCore.Docs-main\aspnetcore\security\authorization\secure-data\samples\final3\Data\SeedData.cs:line 26
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at System.Threading.Tasks.Task.Wait()
at ContactManager.Program.Main(String[] args) in C:\Temp\init-db-issue\main\AspNetCore.Docs-main\aspnetcore\security\authorization\secure-data\samples\final3\Program.cs:line 35
info: Microsoft.Hosting.Lifetime[0]
Now listening on: http://localhost:5000
info: Microsoft.Hosting.Lifetime[0]
Now listening on: https://localhost:5001
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
Content root path: C:\Temp\init-db-issue\main\AspNetCore.Docs-main\aspnetcore\security\authorization\secure-data\samples\final3
Note the following part:
fail: ContactManager.Program[0]
An error occurred seeding the DB.
System.AggregateException: One or more errors occurred. (Value cannot be null. (Parameter 'password'))
Now, load the project in vs but do not run it from there:
Start-Process .\ContactManager.csproj
Run the app from the PowerShell prompt:
dotnet run
Now I don't get the message An error occurred seeding the DB and the DB is indeed seeded.
Question:
Why does the issue go away when we simply load the project into Visual Studio? I would expect the project to work fine when running it via dotnet run without needing to also run Visual Studio. Is this a bug? Or is it due to some aspect of how the project is setup?
The project can be viewed here.
This project is the example used in the following tutorial:
Create an ASP.NET Core web app with user data protected by authorization
The issue is that Properties/launchSettings.json does not exist.
See this comment:
https://github.com/dotnet/AspNetCore.Docs/issues/21668#issuecomment-795543707
Here's a minimal test case which demonstrates the issue:
cd C:\Temp
mkdir init-db-issue-new-app
cd init-db-issue-new-app
dotnet new webapp -o ContactManager -au Individual -uld
cd .\ContactManager
dotnet user-secrets set SeedUserPW abc
#"
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System;
namespace ContactManager
{
public class Program
{
public static void Main(string[] args)
{
var host = CreateHostBuilder(args).Build();
var config = host.Services.GetRequiredService<IConfiguration>();
var testUserPw = config["SeedUserPW"];
Console.WriteLine("{0}", testUserPw);
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
}
"# | Set-Content .\Program.cs
dotnet run # abc is displayed
mv .\Properties\launchSettings.json .\Properties\_launchSettings.json
dotnet run # abc is not displayed
Related
I am trying to run a .Net Core based Azure Function inside a Docker container on a M1 Macbook without success so far.
Originally I used the Azure Function Core Tools CLI to create the function with the following command: func init LocalFunctionsProject --worker-runtime dotnet --docker which created the following Dockerfile.
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS installer-env
COPY . /src/dotnet-function-app
RUN cd /src/dotnet-function-app && \
mkdir -p /home/site/wwwroot && \
dotnet publish *.csproj --output /home/site/wwwroot
# To enable ssh & remote debugging on app service change the base image to the one below
# FROM mcr.microsoft.com/azure-functions/dotnet:3.0-appservice
FROM mcr.microsoft.com/azure-functions/dotnet:3.0
ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
AzureFunctionsJobHost__Logging__Console__IsEnabled=true
COPY --from=installer-env ["/home/site/wwwroot", "/home/site/wwwroot"]
Building the Docker image and running as Container works just fine on a amd based machine. In the meanwhile I got myself a M1 Macbook on which running the Azure Function inside a Docker Container does not work anymore. It gives me the following exception:
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
Unhandled exception. System.IO.IOException: Function not implemented
at System.IO.FileSystemWatcher.StartRaisingEvents()
at System.IO.FileSystemWatcher.StartRaisingEventsIfNotDisposed()
at System.IO.FileSystemWatcher.set_EnableRaisingEvents(Boolean value)
at Microsoft.Extensions.FileProviders.Physical.PhysicalFilesWatcher.TryEnableFileSystemWatcher()
at Microsoft.Extensions.FileProviders.Physical.PhysicalFilesWatcher.CreateFileChangeToken(String filter)
at Microsoft.Extensions.FileProviders.PhysicalFileProvider.Watch(String filter)
at Microsoft.Extensions.Configuration.FileConfigurationProvider.<.ctor>b__1_0()
at Microsoft.Extensions.Primitives.ChangeToken.ChangeTokenRegistration`1..ctor(Func`1 changeTokenProducer, Action`1 changeTokenConsumer, TState state)
at Microsoft.Extensions.Primitives.ChangeToken.OnChange(Func`1 changeTokenProducer, Action changeTokenConsumer)
at Microsoft.Extensions.Configuration.FileConfigurationProvider..ctor(FileConfigurationSource source)
at Microsoft.Extensions.Configuration.Json.JsonConfigurationSource.Build(IConfigurationBuilder builder)
at Microsoft.Extensions.Configuration.ConfigurationBuilder.Build()
at Microsoft.AspNetCore.Hosting.WebHostBuilder.BuildCommonServices(AggregateException& hostingStartupErrors)
at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()
at Microsoft.Azure.WebJobs.Script.WebHost.Program.BuildWebHost(String[] args) in /src/azure-functions-host/src/WebJobs.Script.WebHost/Program.cs:line 35
at Microsoft.Azure.WebJobs.Script.WebHost.Program.Main(String[] args) in /src/azure-functions-host/src/WebJobs.Script.WebHost/Program.cs:line 25
qemu: uncaught target signal 6 (Aborted) - core dumped
What I tried so far
Forcing Docker to use amd based base image by adding --platform=linux/amd64 to the FROM section of the first stage in the Dockerfile which gives me the following error message:
> [installer-env 3/3] RUN cd /src/dotnet-function-app && mkdir -p /home/site/wwwroot && dotnet publish *.csproj --output /home/site/wwwroot:
#9 3.258 Microsoft (R) Build Engine version 16.7.2+b60ddb6f4 for .NET
#9 3.258 Copyright (C) Microsoft Corporation. All rights reserved.
#9 3.258
#9 3.441 qemu: uncaught target signal 11 (Segmentation fault) - core dumped
#9 3.456 Segmentation fault
------
executor failed running [/bin/sh -c cd /src/dotnet-function-app && mkdir -p /home/site/wwwroot && dotnet publish *.csproj --output /home/site/wwwroot]: exit code: 139
Changing the base image of the second stage to mcr.microsoft.com/azure-functions/dotnet:3.0-arm32v7 which gave me the following error:
WARNING: The requested image's platform (linux/arm) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
A fatal error occurred, the folder [/usr/share/dotnet/host/fxr] does not contain any version-numbered child folders
Conclusion
My personal conclusion from how I understand the problem is that probably it will not work on my M1 machine unless there is a dedicated azure-function/dotnet image for arm64 v8 machines. If I am completely wrong, please hint me to the right direction.
I am trying to "dockerize" this clean architecture template for .net Core 3. I use the docker pull request here as the base for my proff of concept app. This is a .net core 3 webapi project with an Angular front end as the client app.
WHAT I HAVE:
The base code from the pull request works locally.
An initial problem I had to overcome was setting the cert for identity server 4 in a local non development env, I had to mount a volume with the cert and reference it from the appsettings.json file like
"IdentityServer": {
"Key": {
"Type": "File",
"FilePath": "/security/mycert.pfx",
"Password": "MyPassword"
}
}
I set up a CI/CD pipeline in azure to build the project and deploy the image to an azure container registry
I set up a CI/CD release to deploy the docker image to a Web App for Containers (Linux) web app. Both these steps work properly
MY PROBLEM:
The web app loads and runs the container and the angular front end is shown. However, it appears that the web api is not running. Any attempt to hit an endpoint of the web api returns the following error in the browser console:
GET https://.....azurewebsites.net/_configuration/CleanArchitecture.WebUI 404 (Not Found)
Error: Uncaught (in promise): Error: Could not load settings for 'CleanArchitecture.WebUI' Error: Could not load settings for 'CleanArchitecture.WebUI'
CleanArchitecture.WebUI is the name of the assembly that is the entry point in the dockerfile:
ENTRYPOINT ["dotnet", "CleanArchitecture.WebUI.dll"]
All other aspects of the front end work properly, only calls to "backend" api fail.
Another issue is that if I get the docker logs from the azure container, there are no errors shown.
WHAT I TRIED
I tried to add "dotnet CleanArchitecture.WebUI.dll" to the startup command of the container in the container settings of the web app, but that just throws an error that it can't find CleanArchitecture.WebUI.dll
I have tried to increase the logging level ("LogLevel": "Default": "Debug") to get more details, but no additional error details are shown in the docker logs.
It might be an error loading the Identity Server 4 certificate, but there are no errors to confirm this problem.
Here is my docker compose file that is used by the azure pipeline:
version: '3.4'
services:
webui:
image: ${DOCKER_REGISTRY-}webui
build:
context: .
dockerfile: src/WebUI/Dockerfile
environment:
- "UseInMemoryDatabase=false"
- "ASPNETCORE_ENVIRONMENT=Production"
- "ConnectionStrings__DefaultConnection=myconnection"
- "ASPNETCORE_Kestrel__Certificates__Default__Password=mypass"
- "ASPNETCORE_Kestrel__Certificates__Default__Path=/security/mycert.pfx"
ports:
- "5000:5000"
- "5001:5001"
volumes:
- mcpdata:"/security:/"
restart: always
mcpdata is the name of the azure file share that gets mounted and contains the actual cert
here is my azure-pipeline.yml for the CI/CD:
trigger:
- staging
resources:
- repo: self
variables:
# Container registry service connection established during pipeline creation
dockerRegistryServiceConnection: '****'
imageRepository: 'cleanarchitecture'
containerRegistry: '****.azurecr.io'
dockerComposeFilePath: '$(Build.SourcesDirectory)docker-compose.Production.yml'
tag: '$(Build.BuildId)'
# Agent VM image name
vmImageName: 'ubuntu-latest'
stages:
- stage: Build
displayName: Build and push stage
jobs:
- job: Build
displayName: Build
pool:
vmImage: $(vmImageName)
steps:
- task: Docker#2
displayName: Build and push an image to container registry
inputs:
command: buildAndPush
repository: $(imageRepository)
dockerComposeFile: $(dockerComposeFilePath)
containerRegistry: $(dockerRegistryServiceConnection)
tags: staging
QUESTION?
Can someone help me figure out why it appears like my web api is not running but no errors are thrown. At a minimum I would be happy if someone could help me see the errors in the docker logs.
thanks in advance
I tried to repeat, with "clean architecture" using the following (note, I'm using zsh on MacOS, but the same should work on Windows/Linux too):
take clean_architecture
dotnet new --install Clean.Architecture.Solution.Template
dotnet new ca-sln
The documentation suggests, clicking F5 in Visual Studio will start the template, although I had to do:
cd src/WebUI/ClientApp
npm install
At this point the app starts locally by hitting F5. Note, what happens here is that ASP.Net Core forwards requests to the dev server, so effectively, this does ng serve --port 53543 AND starts Asp.Net Core (Kestrel in my case) on port 5001, browsing to http://127.0.0.1:53543 provides the angular page directly. Browsing to https://localhost:5001 brings up the same angular page, as forwarded by ASPNetCore to Angular. All very confusing... Detailed more here
Note in Startup.cs the following lines of code exist, these are usually set based on the environment variable ASPNETCORE_ENVIRONMENT
if (!env.IsDevelopment())
{
app.UseSpaStaticFiles();
}
-- and within "app.UseSpa"
if (env.IsDevelopment())
{
spa.UseAngularCliServer(npmScript: "start");
}
Anyway, it looks like you've got that environment variable set to Production, which should just serve the built files from the ClientApp\dist folder (rather than forwarding to the dev server) that suggests that if you see the Angular, then the .Net Core service is running... I'll try and rebuild the Dockerfiles first...
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base
ENV ASPNETCORE_URLS=https://+:5001;http://+:5000
WORKDIR /app
EXPOSE 5000
EXPOSE 5001
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash -
RUN apt install -y nodejs
WORKDIR /src
COPY ./src/WebUI/WebUI.csproj src/WebUI/
COPY ./src/Application/Application.csproj src/Application/
COPY ./src/Domain/Domain.csproj src/Domain/
COPY ./src/Infrastructure/Infrastructure.csproj src/Infrastructure/
RUN dotnet restore "src/WebUI/WebUI.csproj"
COPY . .
WORKDIR "/src/src/WebUI"
RUN dotnet build "WebUI.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "WebUI.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "CleanArchitecture.WebUI.dll"]
Then build and run as follows:
# build takes a while
docker build -f ./src/WebUI/Dockerfile -t clean-architecture .
# note, this fails first time, because I set up as clean_architecture so the entry point is incorrect
docker run --rm -it -p 5000:5000 -p 5001:5001 clean-architecture
# run the container and override the entrypoint
docker run --rm -it --entrypoint /bin/bash clean-architecture
# From within the container...
root#93afb0ad21c5:/app# dotnet clean_architecture.WebUI.dll
# note, in .Net 3.1, you can also do this directly, as follows:
root#93afb0ad21c5:/app# ./clean_architecture.WebUI
Now there is a problem with LocalDB: System.PlatformNotSupportedException: LocalDB is not supported on this platform.
Switch appsettings.Production.json to be "UseInMemoryDatabase": true
The problem then appears to be certificates...
I created a certificate using:
dotnet dev-certs https -ep ./https/clean-arch.pfx -p anything
For IdentityServer, I change appSettings.Production.json as follows:
"IdentityServer": {
"Key": {
"Type": "File",
"FilePath": "/app/https/https/clean-arch.pfx",
"Password": "anything"
}
}
and then running on Linux, probably means running Kestrel, which means we need to provide HTTPS certs there too, which I did by setting the following in Program.cs
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.ConfigureKestrel((context, options) =>
{
options.AllowSynchronousIO = true;
options.Listen(IPAddress.Loopback, 5000, listenOptions =>
{
listenOptions.UseConnectionLogging();
listenOptions.Protocols = Microsoft.AspNetCore.Server.Kestrel.Core.HttpProtocols.Http1AndHttp2;
});
options.Listen(IPAddress.Any, 5001, listenOptions =>
{
listenOptions.UseConnectionLogging();
listenOptions.Protocols = Microsoft.AspNetCore.Server.Kestrel.Core.HttpProtocols.Http1AndHttp2;
listenOptions.UseHttps(new System.Security.Cryptography.X509Certificates.X509Certificate2("/app/https/https/clean-arch.pfx", "anything"));
});
});
webBuilder.UseStartup<Startup>();
});
At each stage I built the app in docker using...
\clean_architecture $ docker build -f ./src/WebUI/Dockerfile -t clean-architecture .
/clean_architecture $ docker run --rm -it -v /Users/monkey/src/csharp/clean_architecture/:/app/https/ -p 5000:5000 -p 5001:5001 --entrypoint /bin/bash clean-architecture
... and once running in bash (in docker), I used the following to start the application:
root#c5b4010d03be:/app# ./clean_architecture.WebUI
Good luck, hope that helps. Note, if it works in Docker, on your machine, it should work in Azure. I'll look at getting it going in Azure another day. Happy to upload my code to GitHub if it would help?
thanks to 0909EM for the huge effort in answering the question, but the solution was different.
I figured out what was going on. There are two issues.
The docer-compose.override.yml file looks like:
version: '3.4'
services:
webui:
environment:
- "ASPNETCORE_ENVIRONMENT=Development"
- "SpaBaseUrl=http://clientapp:4200"
clientapp:
image: ${DOCKER_REGISTRY-}clientapp
build:
context: src/WebUI/ClientApp
dockerfile: Dockerfile
depends_on:
- webui
restart: on-failure
db:
ports:
- "1433:1433"
notice the line dockerfile: Dockerfile in the src/webui/clientapp context. This dockerfile was overwriting the proper docker file in src/webui during the azure pipeline build. For some reason when I run the following command locally: docker-compose -f 'docker-compose.Production.yml' up --build it does not pull in the docker-compose.override settings, but the override settings do get used in the azure pipeline build.
Therefore, the angular dockerfile is the only one built and that image does not contain the .net core web api project. Which explains why I see the front end but cannot get to the api endpoints and also why the dockerfile has no .net core errors.
I was able to fix this in two ways.
First: rename the dockerfile in src/webui/clientapp to Dockerfile.clientapp and change the line in the docker.overrride file to dockerfile: Dockerfile.clientapp
SECOND: just remove the docker override file from the online repository that the azure pipeline pulls from.
As a result the proper dockerfile is used and the web api project is in the image.
The second issue: Now that the proper image is running, the .net core web api throws an error about loading the cert for identity server. This confirms my suspicion. Because this issue is not related to my original question about getting the web api running in the container, i have opened another question about it.
I've been following the documentation on dotnet spark to get started with the library on Windows. This guide can be found:
On the GitHub: https://github.com/dotnet/spark/blob/master/docs/getting-started/windows-instructions.md
On Microsoft documentation: https://learn.microsoft.com/en-us/dotnet/spark/tutorials/get-started
I can't seem to create a spark session with C#. I have spark installed on command line and can run it inside of command line. Here's the code I've been using, same as the guide.
using Microsoft.Spark.Sql;
namespace HelloSpark
{
class Program
{
static void Main(string[] args)
{
var spark = SparkSession.Builder().GetOrCreate();
var df = spark.Read().Json("people.json");
df.Show();
}
}
}
When I run the program inside of Visual Studio, I get the error:
System.Net.Internals.SocketExceptionFactory.ExtendedSocketException:
'No connection could be made because the target machine actively refused it 127.0.0.1:5567'
On the line:
var spark = SparkSession.Builder().GetOrCreate();
I ended up reinstalling the package (Microsoft.Spark) and then running the debug command given here in powershell. After running the command I was able to attach the Visual Studio debugger to that process, and could successfully create a spark session with the C# code.
You are trying to debug your solution directly from visual studio. You need to create a deployment environment. In order to do that you need to launch as it says on the section "Run your .NET for Apache Spark app" from the second link that you posted yourself.
Open powershell and type:
spark-submit `
--class org.apache.spark.deploy.dotnet.DotnetRunner `
--master local `
microsoft-spark-2.4.x-<version>.jar `
dotnet HelloSpark.dll
If you just need to debug, type:
spark-submit `
--class org.apache.spark.deploy.dotnet.DotnetRunner `
--master local `
microsoft-spark-2.4.x-<version>.jar
debug
And work from Visual studio as usual.
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"]
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.
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.
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)
Same problem here. Update Ubuntu kernel to last version (5.0.0-27-generic) solve the problem.
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 :-(
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"]
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
Solutions
apt-add-repository -y ppa:teejee2008/ppa
apt-get update
apt-get install ukuu
ukuu --install-latest
reboot
uname -sr
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.
I received the following information when i was try to build Jenkins C# project:
[Project_Name] $ O:\sonar-runner-2.4\bin\sonar-runner.bat -e -Dsonar.jdbc.url=jdbc:jtds:sqlserver://database.net/sonar;SelectMethod=Cursor ******** ******** -Dsonar.host.url=http://sonar.net:9000 ******** ******** -Dsonar.projectBaseDir=o:\jenkins\workspace\Project_Name -Dsonar.jdbc.password=******* -Dsonar.jdbc.username=sonar
O:/sonar-runner-2.4/
SonarQube Runner 2.4
Java 1.8.0_45 Oracle Corporation (64-bit)
Windows Server 2008 R2 6.1 amd64
INFO: Error stacktraces are turned on.
INFO: Runner configuration file: O:\sonar-runner-2.4\conf\sonar-runner.properties
INFO: Project configuration file: o:\jenkins\workspace\Project_Name\sonar-project.properties
INFO: Default locale: "en_US", source code encoding: "windows-1252" (analysis is platform dependent)
INFO: Work directory: o:\jenkins\workspace\Project_Name\.sonar
INFO: SonarQube Server 5.1
15:44:26.946 INFO - Load global repositories
15:44:27.433 INFO - Load global repositories (done) | time=490ms
15:44:27.438 INFO - Server id: ************
15:44:27.445 INFO - User cache: C:\Users\19231\.sonar\cache
15:44:27.465 INFO - Install plugins
15:44:27.787 INFO - Install JDBC driver
15:44:27.797 INFO - Create JDBC datasource for jdbc:jtds:sqlserver://sonar.net/sonar;SelectMethod=Cursor
15:44:29.808 INFO - Initializing Hibernate
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 6.230s
Final Memory: 15M/451M
INFO: ------------------------------------------------------------------------
ERROR: Error during Sonar runner execution
org.sonar.runner.impl.RunnerException: Unable to execute Sonar
at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:91)
at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75)
at java.security.AccessController.doPrivileged(Native Method)
at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)
at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102)
at org.sonar.runner.api.Runner.execute(Runner.java:100)
at org.sonar.runner.Main.executeTask(Main.java:70)
at org.sonar.runner.Main.execute(Main.java:59)
at org.sonar.runner.Main.main(Main.java:53)
Caused by: java.lang.IllegalStateException: You must define the following mandatory properties for 'my:AllocationAssistant': sonar.sources
at org.sonar.batch.scan.ProjectReactorBuilder.checkMandatoryProperties(ProjectReactorBuilder.java:315)
at org.sonar.batch.scan.ProjectReactorBuilder.defineRootProject(ProjectReactorBuilder.java:157)
at org.sonar.batch.scan.ProjectReactorBuilder.execute(ProjectReactorBuilder.java:116)
at org.sonar.batch.scan.ProjectScanContainer.projectBootstrap(ProjectScanContainer.java:110)
at org.sonar.batch.scan.ProjectScanContainer.doBeforeStart(ProjectScanContainer.java:86)
at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:90)
at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
at org.sonar.batch.scan.ScanTask.scan(ScanTask.java:57)
at org.sonar.batch.scan.ScanTask.execute(ScanTask.java:45)
at org.sonar.batch.bootstrap.TaskContainer.doAfterStart(TaskContainer.java:135)
at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)
at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
at org.sonar.batch.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:158)
at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:95)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:67)
at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:48)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:87)
... 9 more
ERROR:
ERROR: Re-run SonarQube Runner using the -X switch to enable full debug logging.
Build step 'Invoke Standalone Sonar Analysis' marked build as failure
Finished: FAILURE
sonar-project.properties file looks like:
sonar.projectKey=my:AllocationAssistant
sonar.projectName=AllocationAssistant
sonar.projectVersion=prd
sonar.source=.
sonar.language=cs
sonar.dotnet.visualstudio.solution.file=AllocationAssistant.sln
sonar.dotnet.excludeGeneratedCode=true
sonar.dotnet.4.0.sdk.directory=C:/Windows/Microsoft.NET/Framework/v4.0.30319
sonar.dotnet.version=4.0
Anybody have an idea what could be wrong with sonar-project.properties?
I assume that there could be problem.
Sonar-project.properties is in the same folder where .sln is located.
I will be grateful for your opinion and help.
There is a typo in your sonar-project.properties configuration file. 'sonar.source' instead of 'sonar.sources'