I was thinking how I could run multiples processes (setting up the dependencies to achieve the final result) in a just dotnet custom command.
I quickly found the target
xml object that I can setup in the .csproj
file.
So this is what I tried:
<Target Name="fuzz" BeforeTargets="Run">
<Exec Command="docker run --name dumpsql -v C:\path\to\postgres1.sql:/docker-entrypoint-initdb.d/postgres1.sql --env POSTGRES_DB=postgres --env POSTGRES_PASSWORD=postdocker -p 5432:5432 -d postgres:latest"/>
<Exec Command="dotnet run"/>
<Exec Command="docker run --name fuzzcontainer schemathesis/schemathesis:stable run --cassette-path /app/cassete.yaml --checks all http://host.docker.internal:5169/swagger/v1/swagger.json"/>
</Target>
Then I could run dotnet msbuild /t:fuzz
The problem:
Exec
, probably, because the dotnet program is still running and it didn't return any code.So how can I force the build to move on to the next Exec
without waiting for a returned code?
Thank you all.
I am able to reproduce your situation:
And this is the way I use to avoid the situation:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<Target Name="fuzz" BeforeTargets="Build">
<Exec Command="echo xxx"/>
<!--<Exec Command="dotnet run"/>-->
<Exec Command="dotnet run > output.log 2> error.log"/>
<Exec Command="echo yyy"/>
</Target>
</Project>
The key is:
dotnet run > output.log 2> error.log
In this way, I can continue my steps and the dotnet run unable to block me any more.
The outputs will be generated into two files.