The Visual Studio Plugin generate files that are used by the Visual Studio IDE, thus making it possible to open the solution into Visual Studio (File - Open - Project/Solution…).
What exactly the visual-studio plugin generates depends on which other plugins are used:
| Plugin | Description |
|---|---|
None |
Generates minimal solution file. |
Adds a project representing the C++ application to the solution file. |
|
Adds a project for each specified linkage representing the shared and/or static library to the solution file. |
Usage
plugins {
`visual-studio`
}
plugins {
id 'visual-studio'
}
The Visual Studio Plugin adds a number of tasks to your project.
The main tasks that you will use are the visualStudio, cleanVisualStudio and openVisualStudio tasks.
Tasks
The following diagram shows the relationships between tasks added by this plugin.
Lifecycle Tasks
visualStudio— Task-
Depends on:
projectNameVisualStudioSolutionand all Visual Studio project file generation tasksGenerates all Visual Studio configuration files.
cleanVisualStudio— Delete-
Depends on: all Visual Studio project and solution file clean tasks
Removes all Visual Studio configuration files.
openVisualStudio- Task-
Depends on:
visualStudioOpen the Visual Studio solution inside the IDE.
IDE Workspace Tasks
projectNameVisualStudioSolution- GenerateSolutionFileTask-
Generates the
.slnfile. This task is only available on the root project.
IDE Project Tasks
C++ Application Plugin Tasks
projectNameVisualStudioProject— GenerateProjectFileTask-
Generates the
.vcxprojfile for the application component. projectNameVisualStudioFilters— GenerateFiltersFileTask-
Generates the
.vcxproj.filtersfile for the application component. mainVisualStudio- Task (lifecycle)-
Depends on:
projectNameVisualStudioProjectandprojectNameVisualStudioFiltersGenerates all Visual Studio project files for the application component.
C++ Library Plugin Tasks
projectNameDllVisualStudioProject— GenerateProjectFileTask-
Generates the
.vcxprojfile for the shared linkage of themaincomponent. projectNameDllVisualStudioFilters— GenerateFiltersFileTask-
Generates the
.vcxproj.filtersfile for the shared linkage of themaincomponent. projectNameLibVisualStudioProject— GenerateProjectFileTask-
Generates the
.vcxprojfile for the static linkage of themaincomponent. projectNameLibVisualStudioFilters— GenerateFiltersFileTask-
Generates the
.vcxproj.filtersfile for the static linkage of themaincomponent. mainVisualStudio- Task (lifecycle)-
Depends on:
projectNameDllVisualStudioProject(for shared linkage),projectNameDllVisualStudioFilters(for shared linkage),projectNameLibVisualStudioProject(for static linkage) andprojectNameLibVisualStudioFilters(for static linkage)Generates all Visual Studio project files for the library component.
Configuration
The Visual Studio Plugin allows for some customization of the generated files. The following sections are shows the customization.
Change solution generated file location
The location of the generated solution can be configured on the root project:
visualStudio {
solution {
solutionFile.setLocation(file("solution.sln"))
}
}
visualStudio {
solution {
solutionFile.location = file('solution.sln')
}
}
Change project generated files location
The location of the generated project files can be configured on any project:
visualStudio {
projects.all {
projectFile.setLocation(file("project.vcxproj"))
filtersFile.setLocation(file("project.vcxproj.filters"))
}
}
visualStudio {
projects.all {
projectFile.location = file('project.vcxproj')
filtersFile.location = file('project.vcxproj.filters')
}
}