0

As the title, we use **/*.csproj commonly for dotnet build project path, it works greatly. But we recently add a dotnet framework project, while we run our build on *nix build agent, we wanna exclude the dotnet framework projects or include the dotnet core projects only, but when I try to update the project path like dotnet pack, I meet the error below:

Project file(s) matching the specified pattern were not found.

but the project path I defined works for dotnet pack project path, I'm so confused. Hope anyone would help.

project path I use:

Business/*.csproj;Models/*.csproj;
**/*.csproj;-FxModels/*.csproj;

issue from https://github.com/MicrosoftDocs/vsts-docs/issues/3981

WeihanLi
  • 87
  • 7

1 Answers1

2

What's the grammar for AzureDevOps dotnet build project path?

There is no special syntax for AzureDevOps dotnet build project path, it just use relative path and wildcard.

When we use the task dotnet build to build the project, we always the syntax **/*.csproj to include all the project in specify branch of the repos. Assuredly, we could also use full path to specify the one project. For example:

In the get source task of the pipeline, we set the repos and branch:

enter image description here

Then, go to the repos to get the relative path of the .net core project:

enter image description here

So, the relative path of the .net core project is /NetCoreLibDemo/NetCoreLibDemo/NetCoreLibDemo.csproj, if you want only build the .net core project only:

enter image description here

How do I add more than one project for dotnet build project path?

You can specify more than one project for dotnet build project path by using **/*.csproj or specify the .sln file.

However, I have pointed out that if you are use the task dotnet pack rather than dotnet build for more than one projects, you can make a pattern negative by prefixing it with -:, like:

enter image description here

It works fine on my side, you can check if it works for you.

Update:

as I mentioned above, dotnet pack projects grammer did not work for dotnet build, so wanna a grammar for dotnet build, that's the point of the question

The grammar -: is specify for dotnet pack. You could get it from states of the option:

enter image description here

enter image description here

So, just like I pointed above, if you want to specify more than one project for dotnet build project path by using **/*.csproj or specify the .sln file.

Hope this helps.

Leo Liu
  • 71,098
  • 10
  • 114
  • 135
  • not so useful for me, everything you mentioned above I'd tried before, dotnet pack grammer is different from dotnet build, and `**/*.csproj` sometimes is not applicable – WeihanLi Jun 18 '19 at 06:30
  • @WeihanLi, Thanks for your reply. I have test the prefixing `;-:` and it works fine on my side with dotnet pack task. If it not work for, could you please share the Path to csproj or nuspec file(s) to pack to me, BTW, do not use `**/*.csproj`, try to use `ProjectA/NetCoreLibDemo/*.csproj;-:ProjectB/ProjectA/*.csproj` instead. – Leo Liu Jun 18 '19 at 06:37
  • it works for `dotnet pack`, but I'm asking for grammer of `dotnet build` task not `dotnet pack`..., as I mentioned above, `dotnet pack` projects grammer did not work for `dotnet build`, so wanna a grammar for `dotnet build`, that's the point of the question – WeihanLi Jun 19 '19 at 02:06
  • @WeihanLi, Got it. Indeed, The grammar `-:` is only specify for dotnet pack. if you want to specify more than one project for dotnet build project path by using `**/*.csproj` or specify the `.sln` file, check my updated answer for some more details. – Leo Liu Jun 19 '19 at 02:21
  • sometimes `**/*.csproj` or `*.sln` is **not applicable** – WeihanLi Jun 19 '19 at 07:34
  • @WeihanLi, If you have any issue when you use `**/*.csproj` or `*.sln`, you can open a new thread with details info. And on that case, you can use the MSBuild to build multiple projects, https://stackoverflow.com/questions/13915636/specify-project-file-of-a-solution-using-msbuild – Leo Liu Jun 19 '19 at 07:37
  • thanks for your tracking and reply, but it seemed to be not so helpful, had you tried in practice? I'd changed the build step for cake build, it works greatly with cake build now. – WeihanLi Jun 20 '19 at 02:40
  • @WeihanLi, Of course, many of my current pipeline build are set up this way **/*.csproj or `.sln`. I'm not sure if this method doesn't work for you due to our pipleline or project settings. Since you have found the way to resolve this issue, you can share your solution with answer, so it could help other community members who get the same issues – Leo Liu Jun 20 '19 at 02:47
  • 1
    Yeah, `**/*.csproj` works in most of cases, while sometimes `**/*.csproj` may contain some projects I do not wanna build, in this case, can not use `**/*.csproj` and `*.sln`. I think the method I use(`cake`) has none business with azure devops, so I do not think it's a recommended answer for the problem. – WeihanLi Jun 20 '19 at 08:55
  • @WeihanLi, If your final question is sometimes **/*.csproj may contain some projects I do not wanna build, using **/*.csproj and *.sln should not work for you. In this case, you can use Msbuild to build it or you can add one more build tasks to build the multiple projects you want. – Leo Liu Jun 20 '19 at 09:02
  • Thanks @leo-liu-msft, I feel it's strange to set up more than one build steps for `dotnet build`, so I question for the grammar for build multi projects like `dotnet pack`, from the answers above you supplied, seemed not support for now. Thanks so much for your effort – WeihanLi Jun 20 '19 at 10:32