Skip to content
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 restore command fails with multiple sln files in the same folder #433

Open
jathok opened this issue Jun 26, 2023 · 1 comment
Open
Labels
bug Something isn't working

Comments

@jathok
Copy link

jathok commented Jun 26, 2023

Describe the bug

The dotnet task utils converts the input path(s), e.g. rootPath:"path/to/my.sln;path/to/other.sln" into working directories for each command, instead of calling the restore with the path as an argument: jfrog-azure-devops-extension/tasks/JFrogDotnet/dotnetBuild.js

This fails the restore, when there are multiple sln files in the same folder.

Current behavior

Executing JFrog CLI Command:
xx\_tool\jf\2.37.3\x64\jf.exe dotnet restore --no-cache --build-name="xx" --build-number="*xx"
08:50:56 [Info] Running dotnet...
MSBUILD : error MSB1011: Specify which project or solution file to use because this folder contains more than one project or solution file.
08:50:56 [Error] exit status 1
##[debug]task result: Failed

Based on the current code, the command is being changed to not include the path to the files anymore, but strip them to the parent folder and loop through these, using them as working directory:

$(Build.SourcesDirectory)/Solutions>  dotnet restore 

instead of the assumed:

>  dotnet restore $(Build.SourcesDirectory)/Solutions/Solution1.sln

Reproduction steps

# File Structure
/
/Solutions/
/Solutions/Solution1.sln
/Solutions/Solution2.sln
- task: JFrogDotnetCore@1
  inputs:
    command: 'restore'
    rootPath: '$(Build.SourcesDirectory)/Solutions/Solution1.sln'

Expected behavior

rootPath input variable accepts semi colon separated .sln paths. From the user perspective, I expected these to be called in the commands as well and be individually restored.

Either make the rootPath variable fail on .sln file inputs to reflect the code behavior or use the actual .sln paths in the arguments (preferred).

Azure DevOps extension name and version

JFrog 2.6.4

JFrog CLI version

Task Version: 1.6.4

Operating system type and version

JFrog Artifactory version (if relevant)

No response

JFrog Xray version (if relevant)

No response

JFrog Distribution version (if relevant)

No response

@jathok jathok added the bug Something isn't working label Jun 26, 2023
@ajrauhala
Copy link

ajrauhala commented Aug 11, 2023

I ran into the same issue today. Found a work-around, though, haven't tested if it works yet.

In the task definition file https://github.com/jfrog/jfrog-azure-devops-extension/blob/v2/tasks/JFrogDotnet/task.json, there is a help text for rootPath input param: "Path to the root directory of a solution/project file to use. If the directory includes more than one sln files, then the first argument passed in the Arguments field should be the name (not the path) of the sln file. Accepts Ant-style patterns."

So put the path in rootPath and add one argument containing your solution name (quoted), it should work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants