Add a project.json based project to a .sln file without using Visual Studio - visual-studio

We have developers that are using VS Code on Linux, Windows, and Mac. We also have developers that are using full Visual Studio on Windows. A problem arises when the former (including me) do not add their projects to the solution, and the latter therefor do not see the projects in the solution.
How can developers add their project.json projects to a sln without having to open Visual Studio?

Nowadays .NET Core SDK allows working with sln files.
Imagine you have a root folder for the solution. All the projects are located under src and test folders.
Then from the solution folder run something like this:
dotnet sln add ./src/Insurance.Domain/Insurance.Domain.csproj
dotnet sln add ./test/Insurance.Domain.Tests/Insurance.Domain.Tests.csproj
You can list the projects in the solution runing
dotnet sln list
Note:
The solution provided above is not going to work with project.json files. Anyway project.json format is obsolete now and you can easilty migrage to csprojs with the latest SDK. Just run in your project folder:
dotnet migrate
and you are good to go.

Related

Folder structure for a Visual Studio 2017 with CMake

I am working in a new project in C++ with Qt that is using CMake to generate the solution.
The project is quite big and it's working fine both in Visual Studio 2017 and QtCreator. Most of the people generate the solution for building using Ninja and import the build to QtCreator. But I prefer working with VS IDE.
The problem is that with QtCreator the Solution Explorer is keeping the folder structure, but in VS, all the projects (libs and dlls) hungs up from the solution (root) so I lose some valuable information.
I am quite new in CMake, and I would like to know if there is a way to generate the VS solution with the same folder structure that the source code has without affecting QtCreator solutions.
CMake does support organizing the projects in your Visual Studio Solution Explorer into folders, so you can name the folders to mirror the directory structure on your system. For example, if your projects are organized like this:
Utilities/LibraryA
Utilities/LibraryB
Executables/tools/ParserExecutable
You can use the set_target_properties command with FOLDER to designate the containing folder for each project in the VS Solution Explorer:
Utilities/CMakeLists.txt:
set_target_properties(LibraryA PROPERTIES FOLDER "Utilities")
set_target_properties(LibraryB PROPERTIES FOLDER "Utilities")
Executables/tools/CMakeLists.txt:
set_target_properties(ParserExecutable PROPERTIES FOLDER "Executables/tools")
You can try to automate this by using CMAKE_CURRENT_SOURCE_DIR instead of naming the folder explicitly, but start with a simple case first!
Also, make sure you add this to your top-level CMake to enable VS folders for your projects.
set_property(GLOBAL PROPERTY USE_FOLDERS ON)

How to open a project.json dotnet project in VS Studio

I have a dotnet core project that I have created using the project.json and VS Code. So there are no .sln or .xproj files.
How do I open this project in VS Studio 2015?
You can open empty VS instance, then File -> Open -> Project/Solution and open your project.json file. This will generate .sln file, that you can use next time.
There is no way you can open this project directly in VS as ASP.NET Core projects now is able to run without using VS on other platforms. If you have created the solution using Yeoman or dotnet CLI, you have to create a blank new project of ASP.NET Core in VS, and drag all the working files to the solution explorer.
It is recommended that you do it once. If you try again and again, it may fail, as happened with me because IIS configuration can change each time.
Note: If you are cloning the project, using Version Control extensions might be helpful.

How do you configure a VS2015 C# project to put the NuGet packages on build in a lib directory?

I am using Visual Studio 2015 Community. I have got a C# project with a bunch of NuGet packages. When I build the project the NuGet assemblies get copied into bin\Release but I don't want them in the root directory of my application, I want them to be put in a lib subdirectory.
The output path build setting doesn't do what I want, it changes the general output directory. I think that it's Visual Studio which copies the NuGet assemblies on build.
I like my projects organized and don't want a bunch of dependency DLLs in the root folder.
One suggestion is that you could think about using the init.ps1. When the NuGet package is installed for the first time or every time the solution is re-opened in Visual Studio, Init.ps1 will runs once for your solution.
Reference Ryan Vice's share us the detailed steps about how to let NuGet copy dlls to [solution root]\lib in this case:
How to copy Nuget content files relative to the solution root

Is it possible to include a program project and a Wix project both in a Visual Studio Solution?

For example, I use Visual Studio to create a mono game project in the solution, and I add another wix project that
when I hit "build solution", the mono game project being build, and wix project build a installer directly afterward.
In this way, I don't need to separate my project everywhere, because I just want some more additional options with One-Click installer.
If I can use Wix, I can customize the installer, but how?
After search for some time, I found this
http://wixtoolset.org/documentation/manual/v3/votive/votive_project_references.html
But, I would like to put two projects in a same solution folder, rather than two separate solution folder. This way, if I change the path, will the link just broke up?
Yes, you can. Simply add a reference to the project from your WIX project.
Note that with project references, you can use variables in your wxs files. For example if your game project were DavidWong.MyGame:
<File Id="MyGame.exe"
Name="$(var.DavidWong.MyGame.TargetFileName)"
Source="$(var.DavidWong.MyGame.TargetPath)" KeyPath="yes" />
See the documentation for more info.
Yes, it can be done ( project reference and $(var.ProjectName.TargetDir) and so on ) but in my experience there are a few reasons not to:
1) When a new version of Visual Studio comes out you might be stuck if a new version of WiX is not yet released to support that version of Visual Studio. I've seen this several times and currently you'd have to run a beta build of WiX v3.10 if you wanted to support Visual Studio 2015.
2) All developers now have to install WiX or get error messages that some projects couldn't be loaded.
3) Some developers will complain that they don't want "setup" code in their .NET solution. I think this is a thin complaint but I kinda get it.
What I like to do is have an application solution and an installer solution. I use postbuild copy commands and MSBuild publish profiles to stage content in a "deploy" folder that models the deployed system and then use that reference that structure in my wix code.

Copy/Move Visual Studio Projects/Solutions To Another Computer

So I have a handful of Visual Studio projects that I need to move to another computer. Is it as simple as a copy and paste or will that mess something up? Both machines will have the same version of Visual Studio installed, so that shouldn't be an issue.
Is there an export function that I've overlooked?
If the Visual Studio version is the same, you can just copy the project folder.
Till the time you are moving your solution file and associated files you should be good.
In case you are using any source control update your solution from there.
Hope you have the same VS version and any addon frameworks you have
You can directly copy the project to the projects folder. This worked perfectly for Visual C++ projects for me (and also some other projects). But when I copied my Cordova App from one PC to the other (Both had Visual Studio 2015), I wasn't able to open the project. Whenever I tried to open the project, trying both the ways - directly from the Project file and the open option in Visual Studio, it at first opened but when I tried to open a file, it just got hung and didn't respond.
This problem may occur because Cordova apps have some configuration files that might be different for different PCs. I am not sure that this is the reason for the problem.
A solution that I used was that I created a new Project and copied the files to the project folders (excluding the configuration files).
Can you save the file to cloud? if so then you could potentially upload the file to cloud and download the file to the new

Resources