diff --git a/docs/users/manifests.md b/docs/users/manifests.md index ae0ee7eedc..0018ff375d 100644 --- a/docs/users/manifests.md +++ b/docs/users/manifests.md @@ -441,7 +441,7 @@ See the `--feature-flags=` command line option for more information. ## MSBuild Integration To use manifests with MSBuild, first you need to use an [existing integration method](integration.md#with-msbuild). -Then, simply add a vcpkg.json above your project file (such as in the root of your source repository) and set the +Then, add a vcpkg.json above your project file (such as in the root of your source repository) and set the property `VcpkgEnableManifest` to `true`. You can set this property via the IDE in `Project Properties -> Vcpkg -> Use Vcpkg Manifest`. @@ -453,9 +453,21 @@ Note: It is critical that all project files in a single build consuming the same you need to use different triplets for different projects in your solution, they must consume from different `vcpkg.json` files. +### Known issues + +* Visual Studio 2015 does not correctly track edits to the `vcpkg.json` and `vcpkg-configuration.json` files, and will +not respond to changes unless a `.cpp` is edited. + ### MSBuild Properties -These properties can be defined via the VS GUI under `Project Properties -> Vcpkg` or via a common `.props` file. +When using Visual Studio 2015 integration, these properties can be set in your project file before the + + + +line, which unfortunately requires manual editing of the `.vcxproj` or passing on the msbuild command line with `/p:`. +With 2017 or later integration, These properties can additionally be set via the Visual Studio GUI under +`Project Properties -> Vcpkg` or via a common `.props` file imported between `Microsoft.Cpp.props` and +`Microsoft.Cpp.targets`. #### `VcpkgEnabled` (Use Vcpkg) @@ -495,7 +507,7 @@ vcpkg.json files will be ignored. This will default to true in the future. This property can be set to "false" to disable automatic dependency restoration on project build. Dependencies can be manually restored via the vcpkg command line. -#### `VcpkgInstalledDirectory` (Installed Directory) +#### `VcpkgInstalledDir` (Installed Directory) This property defines the location where headers and binaries are consumed from. In manifest mode, this directory is created and populated based on your manifest. diff --git a/scripts/buildsystems/msbuild/vcpkg.props b/scripts/buildsystems/msbuild/vcpkg.props index 788ba107b5..9a01beb5ad 100644 --- a/scripts/buildsystems/msbuild/vcpkg.props +++ b/scripts/buildsystems/msbuild/vcpkg.props @@ -1,34 +1,21 @@ - - - - windows - uwp - - - - - $(Platform) - x86 - - true true $(Configuration) false - $([System.IO.Path]::Combine($(MSBuildThisFileDirectory), '..\..\..')) + $([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)..\..\..')) true false + true false true $([MSbuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), vcpkg.json)) - diff --git a/scripts/buildsystems/msbuild/vcpkg.targets b/scripts/buildsystems/msbuild/vcpkg.targets index 7653c4e91f..98fde24f12 100644 --- a/scripts/buildsystems/msbuild/vcpkg.targets +++ b/scripts/buildsystems/msbuild/vcpkg.targets @@ -1,53 +1,91 @@ - + - - - - $([System.IO.Path]::Combine($(VcpkgRoot), 'scripts\buildsystems\msbuild\vcpkg-general.xml')) + + + + <_ZVcpkgRoot>$(VcpkgRoot) + <_ZVcpkgManifestRoot>$(VcpkgManifestRoot) + <_ZVcpkgInstalledDir>$(VcpkgInstalledDir) - - - - -static - $(VcpkgPlatformTarget)-$(VcpkgOSTarget)$(VcpkgLinkage) + + + <_ZVcpkgRoot Condition="!$(_ZVcpkgRoot.EndsWith('\'))">$(_ZVcpkgRoot)\ + <_ZVcpkgManifestRoot Condition="'$(_ZVcpkgManifestRoot)' != '' and !$(_ZVcpkgManifestRoot.EndsWith('\'))">$(_ZVcpkgManifestRoot)\ + <_ZVcpkgInstalledDir Condition="'$(_ZVcpkgInstalledDir)' != '' and !$(_ZVcpkgInstalledDir.EndsWith('\'))">$(_ZVcpkgInstalledDir)\ + - $(VcpkgRoot)\ - $(VcpkgManifestRoot)\ + + + windows + uwp + - $([System.IO.Path]::Combine($(VcpkgRoot), 'installed')) - $([System.IO.Path]::Combine($(VcpkgManifestRoot), 'vcpkg_installed')) - $(VcpkgInstalledDir)\ + + $(Platform) + x86 + - <_ZVcpkgCurrentInstalledDir>$([System.IO.Path]::Combine($(VcpkgInstalledDir), $(VcpkgTriplet))) - <_ZVcpkgCurrentInstalledDir Condition="!$(_ZVcpkgCurrentInstalledDir.EndsWith('\'))">$(_ZVcpkgCurrentInstalledDir)\ - - Debug - Release - - debug\ - true - - <_ZVcpkgHostTripletParameter Condition="'$(VcpkgHostTriplet)' != ''">"--host-triplet=$(VcpkgHostTriplet)" - <_ZVcpkgExecutable>$([System.IO.Path]::Combine($(VcpkgRoot), 'vcpkg.exe')) + + <_ZVcpkgLinkage /> + <_ZVcpkgLinkage Condition="'$(VcpkgUseStatic)' == 'true'">-static + $(VcpkgPlatformTarget)-$(VcpkgOSTarget)$(_ZVcpkgLinkage) + + + VcpkgTriplet=$(VcpkgTriplet):$(ProjectStateLine) - - + + + + + <_ZVcpkgInstalledDir Condition="'$(_ZVcpkgInstalledDir)' == ''">$(_ZVcpkgManifestRoot)vcpkg_installed\$(VcpkgTriplet)\ + + + + + <_ZVcpkgInstalledDir Condition="'$(_ZVcpkgInstalledDir)' == ''">$(_ZVcpkgRoot)installed\ + + + + + + <_ZVcpkgCurrentInstalledDir>$(_ZVcpkgInstalledDir)\$(VcpkgTriplet)\ + <_ZVcpkgNormalizedConfiguration Condition="$(VcpkgConfiguration.StartsWith('Debug'))">Debug + <_ZVcpkgNormalizedConfiguration Condition="$(VcpkgConfiguration.StartsWith('Release')) or '$(VcpkgConfiguration)' == 'RelWithDebInfo' or '$(VcpkgConfiguration)' == 'MinSizeRel'">Release + + <_ZVcpkgConfigSubdir Condition="'$(_ZVcpkgNormalizedConfiguration)' == 'Debug'">debug\ + <_ZVcpkgExecutable>$(_ZVcpkgRoot)vcpkg.exe + + + + + $(_ZVcpkgRoot)scripts\buildsystems\msbuild\vcpkg-general.xml + + + Project + - %(AdditionalDependencies);$(_ZVcpkgCurrentInstalledDir)$(VcpkgConfigSubdir)lib\*.lib - %(AdditionalLibraryDirectories);$(_ZVcpkgCurrentInstalledDir)$(VcpkgConfigSubdir)lib;$(_ZVcpkgCurrentInstalledDir)$(VcpkgConfigSubdir)lib\manual-link + %(AdditionalDependencies);$(_ZVcpkgCurrentInstalledDir)$(_ZVcpkgConfigSubdir)lib\*.lib + %(AdditionalLibraryDirectories);$(_ZVcpkgCurrentInstalledDir)$(_ZVcpkgConfigSubdir)lib;$(_ZVcpkgCurrentInstalledDir)$(_ZVcpkgConfigSubdir)lib\manual-link %(AdditionalIncludeDirectories);$(_ZVcpkgCurrentInstalledDir)include @@ -59,9 +97,9 @@ - + Condition="'$(VcpkgEnableManifest)' == 'true' and '$(_ZVcpkgManifestRoot)' == ''" /> + @@ -70,41 +108,52 @@ + Importance="High" Condition="'$(VcpkgEnabled)' == 'true' and '$(_ZVcpkgNormalizedConfiguration)' == ''"/> - - <_ZVcpkgManifestFileLocation>$(VcpkgManifestRoot)vcpkg.json - <_ZVcpkgConfigurationFileLocation>$(VcpkgManifestRoot)vcpkg-configuration.json + + + + <_ZVcpkgHostTripletParameter>"--host-triplet=$(VcpkgHostTriplet)" + <_ZVcpkgHostTripletSuffix>$(VcpkgHostTriplet). + + + + + <_ZVcpkgHostTripletParameter /> + <_ZVcpkgHostTripletSuffix /> + + + - <_ZVcpkgTLogFileLocation>$(TLogLocation)VcpkgInstallManifest$(VcpkgTriplet).$(VcpkgHostTriplet).read.1u.tlog - <_ZVcpkgMSBuildStampFile>$(VcpkgInstalledDir).msbuildstamp-$(VcpkgTriplet).$(VcpkgHostTriplet).stamp + + <_ZVcpkgManifestFileLocation>$(_ZVcpkgManifestRoot)vcpkg.json + <_ZVcpkgConfigurationFileLocation>$(_ZVcpkgManifestRoot)vcpkg-configuration.json + <_ZVcpkgMSBuildStampFile>$(_ZVcpkgInstalledDir).msbuildstamp-$(VcpkgTriplet).$(_ZVcpkgHostTripletSuffix)stamp + <_ZVcpkgInstallManifestDependenciesInputs Include="$(_ZVcpkgManifestFileLocation)"/> <_ZVcpkgInstallManifestDependenciesInputs Include="$(_ZVcpkgConfigurationFileLocation)" Condition="Exists('$(_ZVcpkgConfigurationFileLocation)')"/> - - <_ZVcpkgInstallManifestDependenciesOutputs Include="$(_ZVcpkgTLogFileLocation)"/> - <_ZVcpkgInstallManifestDependenciesOutputs Include="$(_ZVcpkgMSBuildStampFile)"/> - - - - <_ZVcpkgItemToDelete Include="$(TLogLocation)VcpkgInstallManifest*.read.1u.tlog" /> - <_ZVcpkgItemToDelete Include="$(VcpkgInstalledDir).msbuildstamp-*" /> - - - + + + <_ZVcpkgTLogFileLocation>$(TLogLocation)VcpkgInstallManifest$(VcpkgTriplet).$(_ZVcpkgHostTripletSuffix)read.1u.tlog + + + + + - @@ -118,40 +167,40 @@ Condition="'$(VcpkgEnabled)' == 'true' and '$(VcpkgApplocalDeps)' == 'true' and '$(LinkSkippedExecution)' != 'true'"> - <_VcpkgAppLocalPowerShellCommonArguments>-ExecutionPolicy Bypass -noprofile -File "$(MSBuildThisFileDirectory)applocal.ps1" "$(TargetPath)" "$(_ZVcpkgCurrentInstalledDir)$(VcpkgConfigSubdir)bin" "$(TLogLocation)$(ProjectName).write.1u.tlog" "$(IntDir)vcpkg.applocal.log" + <_ZVcpkgAppLocalPowerShellCommonArguments>-ExecutionPolicy Bypass -noprofile -File "$(MSBuildThisFileDirectory)applocal.ps1" "$(TargetPath)" "$(_ZVcpkgCurrentInstalledDir)$(_ZVcpkgConfigSubdir)bin" "$(TLogLocation)$(ProjectName).write.1u.tlog" "$(IntDir)vcpkg.applocal.log" + PropertyName="_ZVcpkgAppLocalExitCode" /> + Condition="$(_ZVcpkgAppLocalExitCode) == 9009" /> + Condition="$(_ZVcpkgAppLocalExitCode) == 9009"> + PropertyName="_ZVcpkgAppLocalExitCode" /> - + + Condition="$(_ZVcpkgAppLocalExitCode) == 0"> - - + +