dotnet / dotnet/msbuild

MSBuild task hangs occasionally in Linux when invoking 'dotnet run'

Open
#9,671 14 comments 1 reaction 0 assignees View on GitHub
Area: Tasks triaged
Dominant language
C#
Stars
5.5k
Forks
1.5k
Avg merge
1d 13h
Merged PRs (30d)
133

Description

## Steps to reproduce
Create a project, add a target that is invoked before target `BeforeBuild`. That task should then invoke ``.

## Expected behavior
I expect the command to run and finish, so that msbuild can continue executing targets.

## Actual behavior
Msbuild seemingly hangs, as if it cannot determine that `OtherProject` has exited. This only occurs in Linux, and only sometimes. It always hangs when I run the same task on the Ubuntu 1604 hosted agent in Azure DevOps. It sometimes hangs when I run the same task in Docker on my Windows desktop machine.

## Environment data
I am using the docker image `microsoft/dotnet:2.2-sdk` as a base for my own image. I have stripped it down to a bare minimum with `/bin/bash` as ENTRYPOINT, so that I have been able to run the commands manually.

`dotnet --info` output:
```
.NET Core SDK (reflecting any global.json):
Version: 2.2.104
Commit: 73f036d4ac

Runtime Environment:
OS Name: debian
OS Version: 9
OS Platform: Linux
RID: debian.9-x64
Base Path: /usr/share/dotnet/sdk/2.2.104/

Host (useful for support):
Version: 2.2.2
Commit: a4fd7b2c84

.NET Core SDKs installed:
2.2.104 [/usr/share/dotnet/sdk]

.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.2.2 [/usr/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.2.2 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.2.2 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download
```

The "offending" target looks like this in my .csproj:
```





```

The project `Tracy.Core.Dal.ModelBuilderGenerator` is a custom project that generates code at runtime for other projects to consume. In the logs I can see all the output from the generator project. The very last output is right before `return 0;`.

The workaround I have now is to tag the target with `Condition="'$(BuildingInsideVisualStudio)' == 'true'"` so that it'll work as expected during development time. During build, I publish the tool in my Docker file to an executable, which I run before the initial `dotnet` invocation.

## Source code access
Access to source code etc can be arranged privately if needed.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.