How to target a .sln file, when running the dotnet publish command inside of a workflow

Socks93

Active member
Joined
Oct 22, 2021
Messages
30
Programming Experience
Beginner
Hi,

I am experiencing the following issue when attempting to deploy a project to the test environment through a workflow (YAML file):

MSBUILD : error MSB1003: Specify a project or solution file. The current working directory does not contain a project or solution file.
Where the issue is being triggered in the workflow:

- name: dotnet publish run: dotnet publish -c SIT -o ${{env.DOTNET_ROOT}}\projectName-api

env.DOTNET_ROOT - C:\Users\admin\AppData\Local\Microsoft\dotnet\projectName-Api

The solution file is another directory (.projectName/Project.sln) which is why I think this issue is occurring.
What I would like to know is, Is there a way to run a separate command to reference the solution file when

dotnet publish -c SIT -o ${{env.DOTNET_ROOT}}\projectName-api is triggered?

If not, what would be the best way to resolve this?

Any help would be much appreciated, thank you!
 
What is the current directory when you initiate the build?

Have you tried changing the current directory before initiating the build?
 
What is the current directory when you initiate the build?

Have you tried changing the current directory before initiating the build?

Hi @Skydiver

The directory for when building the project is completely different:

- name: Build with dotnet run: dotnet build ./ProjectName/web/ProjectName-core-api/ProjectName-core-api.csproj --configuration SIT

The Directory that is used when publishing the project:

- name: dotnet publish run: dotnet publish -c SIT -o ${{env.DOTNET_ROOT}}\ProjectName-core-api

What the dotnet publish directory looks like in GitHub when the workflow is running:

dotnet publish -c SIT -o C:\Users\runneradmin\AppData\Local\Microsoft\dotnet/ProjectName-core-api

This is something which I've been asked to look into but, I if the Project solution is in a different folder how would I be able to access that?
 
Read the error message. It specifically says that the current working directory does not contain the solution file. Therefore change the current working directory before starting the build.
 
Alternatively, dotnet publish takes the path to the project or solution file as the first parameter. See the documentation:
 
In my workflow I do a checkout using actions/checkout@v3 and then the project is in the current directory for dotnet build and dotnet publish; they only specify the project's filename. And you say solution file but probably we just need to specify the project file.
 
Back
Top Bottom