'How to deploy minimal ASP.NET/Razor WebApp with Github Workflow using VS 2022 CI/CD feature to generate YAML?

Background:

I'm trying to use that Visual Studio (2022) CI/CD feature (part of the publish feature) that automatically generates the workflow YAML file in the .github/workflows directory.

When I trigger the workflow with a push, I always get this same error:

MSBUILD : error MSB1003: Specify a project or solution file. The current working directory does not contain a project or solution file.
Error: Process completed with exit code 1.

I clearly have a .csproj file that is being committed and checked in... You can see it in my git hub repo.

What I have tried:

I've been following these directions that make no mention have having to edit the YAML file.

As can bee seen here .github/workflows/xyfolxgnipoogweb.yml and here and again here) I've been trying to guide it to my project files as per this Microsoft example that demonstrates the paths: '**.csproj' syntax and github copilot suggestions and bing/google searching... Nothing works (so far).

Is it necessary to edit this YAML file generated by Visual Studio? If not, what could be wrong?

Thanks

Siegfried



Solution 1:[1]

Note: I had some trouble with the repository linked in the original problem statement above and I have since created another github repo (again)...

Problem: Wrong Directory!

Visual Studio 2022 generates this code:

env:
...
  WORKING_DIRECTORY: .
jobs:

Resolution: Specify the child directory where the source code is!

The above code is incorrect and it necessary to manually edit the file specify the correct directory:

env:
...
  WORKING_DIRECTORY: ./DemoVisualStudioCICDForBlazorServer
jobs:

Diagnosing the Problem:

Adding this diagnostic code helped identify the problem:

    - name: Where are we
      run: echo "Hello from $PWD"

I hope this will help someone else someday.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1