dotnet migrate on a project that only contains project.json projects (example)
The projects are migrated to csproj and a solution is created OR the tool chain allows multiple projects to be specified as before.
The projects are migrated, but a solution is not created. This means there is no easy way to restore and build, since dotnet restore only allows you to specify one project at a time and dotnet build seems to want a solution now instead of searching for projects. Perhaps I missed a communication?
dotnet --info output:
.NET Command Line Tools (1.0.0-rc4-004771)
Product Information:
Version: 1.0.0-rc4-004771
Commit SHA-1 hash: 4228198f0e
Runtime Environment:
OS Name: arch
OS Version:
OS Platform: Linux
RID: ubuntu.14.04-x64
Base Path: /opt/dotnet/sdk/1.0.0-rc4-004771
@nlowe great suggestion!
For the time being, your scenario should still work. When we migrate multiple related project.json projects we wire up appropriate references between them. That allows you to go to the root project, the one no other project depends on, and restore and build it. The tools are smart enough to determine that dependencies of that project also need to be restored & built and they do that automatically!
I'm putting the suggestion in 2.0.0 milestone. This would be cool to provide, at least as an option.
Correct, but I still have to do something like find . -type f -name '*.csproj' -exec dotnet restore {} \; whereas previously I could just issue dotnet restore from the project root. I can adapt build scripts (cake), but I still feel this is a loss of functionality.
Additionally, it seems dotnet build **/*.csproj no longer works. IIRC you used to be able to dotnet build **/project.json.
From what I understand, creating a solution should resolve this, but unless you hack one together manually I think you need to use Visual Studio (not available on linux) or Jetbrains Rider or something similar
Luckily, you no longer need to hack one together manually ๐ ๐
MacBook-Pro:foobar martin$ dotnet new solution
Content generation time: 20.3027 ms
The template "Solution File" created successfully.
MacBook-Pro:foobar martin$ dotnet sln add **/*.csproj
Project `app1/app1.csproj` added to the solution.
Project `app2/app2.csproj` added to the solution.
Is file globbing broken in linux?
[nathan@nathan-arch netcore-multiproject]$ dotnet sln add **/*.csproj
Project `**/*.csproj` does not exist.
.NET Add project(s) to a solution file Command
Usage: dotnet sln <SLN_FILE> add [options] [args]
Arguments:
<SLN_FILE> Solution file to operate on. If not specified, the command will search the current directory for one.
Options:
-h|--help Show help information
Additional Arguments:
Add a specified project(s) to the solution.
[nathan@nathan-arch netcore-multiproject]$ tree
.
โโโ backup
โย ย โโโ global.json
โย ย โโโ src
โย ย โย ย โโโ MyProject
โย ย โย ย โย ย โโโ project.json
โย ย โย ย โโโ MyProject.Types
โย ย โย ย โย ย โโโ MyProject.Types.csproj
โย ย โย ย โย ย โโโ obj
โย ย โย ย โย ย โย ย โโโ MyProject.Types.csproj.nuget.g.props
โย ย โย ย โย ย โย ย โโโ MyProject.Types.csproj.nuget.g.targets
โย ย โย ย โย ย โย ย โโโ project.assets.json
โย ย โย ย โย ย โโโ project.json
โย ย โย ย โโโ MyProject.Web
โย ย โย ย โโโ project.json
โย ย โโโ test
โย ย โโโ MyProject.Tests
โย ย โโโ project.json
โโโ build.cake
โโโ build.ps1
โโโ build.sh
โโโ netcore-multiproject.sln
โโโ src
โย ย โโโ MyProject
โย ย โย ย โโโ MyProject.csproj
โย ย โย ย โโโ Program.cs
โย ย โโโ MyProject.Types
โย ย โย ย โโโ Library.cs
โย ย โย ย โโโ MyProject.Types.csproj
โย ย โย ย โโโ obj
โย ย โย ย โโโ MyProject.Types.csproj.nuget.g.props
โย ย โย ย โโโ MyProject.Types.csproj.nuget.g.targets
โย ย โย ย โโโ project.assets.json
โย ย โโโ MyProject.Web
โย ย โโโ bower.json
โย ย โโโ Controllers
โย ย โย ย โโโ TestController.cs
โย ย โโโ MyProject.Web.csproj
โย ย โโโ package.json
โย ย โโโ Program.cs
โย ย โโโ Properties
โย ย โย ย โโโ launchSettings.json
โย ย โโโ README.md
โย ย โโโ Startup.cs
โย ย โโโ Views
โย ย โย ย โโโ Shared
โย ย โย ย โย ย โโโ _Layout.cshtml
โย ย โย ย โโโ Test
โย ย โย ย โย ย โโโ Index.cshtml
โย ย โย ย โโโ _ViewStart.cshtml
โย ย โโโ web.config
โโโ test
โย ย โโโ MyProject.Tests
โย ย โโโ MyProject.Tests.csproj
โย ย โโโ Tests.cs
โโโ tools
โโโ nuget.exe
21 directories, 35 files
EDIT: I also tried dotnet sln netcore-multiproject.sln add **/*.csproj as suggested by the error message, same result.
This worked however:
[nathan@nathan-arch netcore-multiproject]$ find . -type f -name '*.csproj' -exec dotnet sln add {} \;
Project `backup/src/MyProject.Types/MyProject.Types.csproj` added to the solution.
Project `test/MyProject.Tests/MyProject.Tests.csproj` added to the solution.
Project `src/MyProject/MyProject.csproj` added to the solution.
Project `src/MyProject.Types/MyProject.Types.csproj` added to the solution.
Project `src/MyProject.Web/MyProject.Web.csproj` added to the solution.
Also, should the solution file really be marked executable?
-rwxr--r-- 1 nathan nathan 5.5K Feb 15 14:42 netcore-multiproject.sln
The executable thing is a standing issue with .net.. there are issues both on the cli and corefx for it.
Globbing should be done by the shell here so it probably depends on the shell version and settings (bash 3.2.57(1) on Mac OS in my case).
So you could also do it via find . -type f -name '*.csproj' -exec dotnet sln add {} \;
This issue was moved to dotnet/cli-migrate#24
Most helpful comment
Luckily, you no longer need to hack one together manually ๐ ๐