I'm trying to design a build script for a dotnet core 2.0 project that does the following actions
- Cleans output directories
- Builds Solution with -o bin\Publish
- Runs Unit Tests with dotnet vstest
- Creates a Nuget package with dotnet pack
Because I know the source code has been built and tested in steps 1-3 I do not want to rebuild my code for the nuget package, so I am specifying --no-build and --no-restore
The difficulty I'm having is that when creating the package, because I am not building and the output directory is set to be bin\Publish - the pack command is looking for items in the bin\Debug directory.
Is there a way I can set the dotnet pack command to know where to look for the already compiled objects?
Here is a sample of my build script
dotnet clean ..\MySolution.sln -o bin/Publish/
dotnet build ..\MySolution.sln /p:Configuration=Release -o bin/Publish/
dotnet vstest ..\MySolution.UnitTests\bin\Publish\MySolution.UnitTests.dll
dotnet pack --no-build --no-restore ..\MySolution.ConsoleApp\MySolution.csproj -o bin\Publish\Nuget\
....
error : The file 'D:\MySolution.ConsoleApp\bin\Debug\netcoreapp2.0\MySolution.ConsoleApp.runtimeconfig.json' to be packed was not found on disk
According to the Microsoft Docs on dotnet pack
"By default, dotnet pack builds the project first. If you wish to avoid this behavior, pass the --no-build option. This is often useful in Continuous Integration (CI) build scenarios where you know the code was previously built."
So I'm hoping that this is possible and I'm missing something obvious. Any help would be appreciated.