-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dotnet custom does not execute in the context of project directories #6249
Comments
There's no expectation for the dotnet task to cd into each proj directory found. According to their README, for dotnet-setversion to work, dotnet should be invoked from the directory the .csproj is on. I think dotnet-setversion should be updated to use the parameters dotnet is called with (which our custom task provides) so that it can do the directory change on its own. I would contact the setversion owner and ask them if they could make the change or take a PR for it. |
Hi @aldoms. I have already raised that as an issue with setversion in order to support the way the VSTS build task invokes the custom CLI. We are now at the point of testing that updated CLI and this is where we are hitting the issue. My understanding of the current state is:
Best I can tell, the issue here is either
Can you please confirm that the correct way of referencing the custom dotnet CLI is via the csproj example above? Is there anything else required in the solution to restore the package? |
Ok, so reading https://docs.microsoft.com/en-us/dotnet/core/tools/extensibility#path-based-extensibility it seems like this setversion CLI is a project specific one. That would explain why the custom command can only be run in the context of the specific project. So my scenario falls in a gap here. The setversion CLI is developed to be a project specific CLI. The dotnet VSTS build step is designed to execute globally installed CLI packages. |
You are correct, after a more thorough reading of the docs the project based tools need to run in the context of the project for dotnet to find the binaries needed for the command. You are correctly specifying the dotnet-setversion reference in your project, we just need to run dotnet in the correct folder. There's a new "workingDirectory" input that will be added to the dotnet task in the advanced section, which will be deployed sometime in the next couple of weeks. Once that goes live, please try it out and see if it satisfies your scenario. On our end we will determine whether to add the change directory capability to the task, or if it's something dotnet should handle itself. |
@roryprimrose this feature should be available to you now. Let me know if this resolves your issue. |
Sorry, I missed these comment notifications. The addition of the workingDirectory parameter will now support using the dotnet task with project based CLI because the CWD can be set. Thank you for making this change. I think there is still a usability issue here where the build task cannot be used to execute project based CLI resolved via a glob. To argue the other side, I'm not sure the build task should do this because doing so would require the glob matched projects to all have the project based CLI configured for it to work otherwise builds would fail on projects that match the glob but don't have the CLI package. This is a good change however does not solve my issue. The primary blocker is that I can't install the setversion CLI as a global package (assume a hosted build agent for example) and duplicating dotnet custom tasks for each csproj in a solution prevents using a glob and therefore is an administrative nightmare. I don't think there is actually a good solution here. I've written a powershell task to set the version against all projects as a broad action on my build workflow which covers my specific need here. |
Thanks @roryprimrose for confirmation and also updating the thread with the work-around in case someone else has this issue. I am closing this ticket right now given we are not planning update the working folder per regex pattern match. |
It would be very useful if the working directory could be set based on the glob match. I'm trying to run As things stand I have to either create a separate task for every new unit test project or use a shell script instead. Creating a new task would not be maintainable and would require VSTS configuration to be changed just to run unit tests for a new project. Creating a shell script to achieve this defeats the point of using VSTS with its easy to use tasks. You could provide an option for setting the working directory per glob match. When that is enabled the specific working directory option could be disabled. Right now, it looks like I'll be writing a script to solve my problem, something I thought that for common cases VSTS was supposed to help me avoid. |
@alexmg I am opening the issue for now. Adding @azooinmyluggage to provide the feedback on this request |
Thanks @sachinma for taking this into consideration. I started out using |
This issue is stale because it has been open for 180 days with no activity. Remove the stale label or comment on the issue otherwise this will be closed in 5 days |
Issue Description
I'm using 2.* beta of the dotnet build task to run a custom dotnet CLI. In this scenario, I'm using setversion from https://github.com/TAGC/dotnet-setversion
I have added the following to one of my projects.
My build does a dotnet restore, then a dotnet custom. For example:
The call to the custom task fails because the task cannot be found. If I use the commandline but execute with the current directory set to the project folder, the custom CLI will be resolved and will execute correctly.
Either there is an issue with the setversion package, or (presumably) the build task needs to set the current directory to each proj found in the glob before executing the custom CLI. I'm not sure which is the issue here.
Error logs
The text was updated successfully, but these errors were encountered: