github-actions

Question about Github Action "setup-donet@v4"


My project workspace action was building and publishing fine with "setup-donet@v1" but fails with "setup-donet@v4" - the dotnet publish command fails with below error. When switching back to v1 its working again.

Run dotnet publish ./Project/Project.csproj -c Release -o C:\Program Files\dotnet/myapp/
MSBUILD : error MSB1008: Only one project can be specified.
    Full command line: 'C:\Program Files\dotnet\sdk\8.0.302\MSBuild.dll -maxcpucount -verbosity:m -nologo -restore -target:Publish --property:_IsPublishing=true -property:PublishDir=C:\Program -property:_CommandLineDefinedOutputPath=true -property:Configuration=Release -property:DOTNET_CLI_DISABLE_PUBLISH_AND_PACK_RELEASE=true ./Project/Project.csproj Files\dotnet/myapp/ -distributedlogger:Microsoft.DotNet.Tools.MSBuild.MSBuildLogger,C:\Program Files\dotnet\sdk\8.0.302\dotnet.dll*Microsoft.DotNet.Tools.MSBuild.MSBuildForwardingLogger,C:\Program Files\dotnet\sdk\8.0.302\dotnet.dll'
  Switches appended by response files:
Switch: Files\dotnet/myapp/

For switch syntax, type "MSBuild -help"
Error: Process completed with exit code 1.

This is the related part of my workflow action

      - name: Set up .NET Core
        uses: actions/setup-dotnet@v4
        with:
          dotnet-version: '8.x' 

      - name: Build with dotnet
        run: dotnet build ./Project/Project.csproj --configuration Release

      - name: dotnet publish
        run: dotnet publish ./Project/Project.csproj -c Release -o ${{env.DOTNET_ROOT}}/myapp/

Would you know why?


Solution

  • Solution by @heretic-monkey in the comment.

    Lack of quotes since DOTNET_ROOT appears to have spaces in it. Try -o "${{env.DOTNET_ROOT}}\myapp"