TAGC / dotnet-setversion

.NET Core CLI tool to update the version information in .NET Core *.csproj files
MIT License
75 stars 16 forks source link

Unexpected behaviour in a directory with multiple csproj files #9

Closed Skulblaka closed 6 years ago

Skulblaka commented 6 years ago

Right now, gitversion uses Directory.EnumerateFileSystemEntries(...).First() to find a file to apply the given version. I would expect execution to fail if there were multiple csproj files in a directory, correlating to other commands like e.g. dotnet build:

>dotnet build
...
MSBUILD : error MSB1011: Specify which project or solution file to use because this folder contains more than one project or solution file.
TAGC commented 6 years ago

As reference (for myself), dotnet build gives this error when invoked in a directory with no solution/project files:

MSBUILD : error MSB1003: Specify a project or solution file. The current working directory does not contain a project or solution file.

And this error when it contains more than one:

MSBUILD : error MSB1011: Specify which project or solution file to use because this folder contains more than one project or solution file.

In both cases the exit code is 1.

TAGC commented 6 years ago

Right now it seems it might not even be possible to run this tool when there isn't exactly one csproj file in the directory anyway. For one thing it's a per-project tool meaning it's impossible to run it without being in a directory with a project folder. If you try you get this:

$ dotnet setversion
No executable found matching command "dotnet-setversion"

On the other hand, if you try to run the tool in a project with more than one csproj file, you get the following error before the entry-point of the tool gets executed:

$ dotnet setversion
Specify which project file to use because this '<<folder>>' contains more than one project file.

With seemingly no way to actually specify the project file to use.

Because of this, I think this is a non-issue in this tool's current state. However, I'll probably need to convert this tool into a global tool to support #6 in which case this will become a concern. I'll keep this open for now.

Skulblaka commented 6 years ago

I have a feature branch in my fork where I converted it into a global tool including a migration guide. Do you want me to create another pull request after you merged with the current one?

TAGC commented 6 years ago

Sure, sounds good. Going to hold off on this until I know why the CI build is failing though. I RDP'd into the build server and for some reason the PowerShell console on it gets stuck executing the dotnet setversion command (it prints the "Setting version: ..." message immediately though and it's just a return 0; after that).

Will need access to a Windows machine to see if I can reproduce the problem locally. I'll have access to one on Monday.

Skulblaka commented 6 years ago

Closing this as running dotnet-setversion isn't possible in a directory with two csproj files, so Directory.EnumerateFileSystemEntries(...) will never emit more than one value.