Skip to content

Commit 93557de

Browse files
committed
Make it work from VS
1 parent f8f115b commit 93557de

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/vcpkg.props

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<PropertyGroup Label="Vcpkg">
44
<VcpkgEnableManifest>true</VcpkgEnableManifest>
5-
<VcpkgInstalledDir>$(MSBuildThisFileDirectory)\vcpkg_installed</VcpkgInstalledDir>
5+
<VcpkgInstalledDir>$(MSBuildThisFileDirectory)vcpkg_installed\</VcpkgInstalledDir>
66
</PropertyGroup>
77
<PropertyGroup Label="Vcpkg" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
88
<VcpkgTriplet>x64</VcpkgTriplet>
@@ -58,7 +58,7 @@
5858
When building the .sln, we will write a file to indicate which triplet should be used in all projects.
5959
Each project will later read this file to verify that it is using the same triplet. -->
6060
<_IsBuildingSln>$(MSBuildProjectName.EndsWith('.sln'))</_IsBuildingSln>
61-
<_TripletFile>$(VcpkgInstalledDir)\.solutiontriplet</_TripletFile>
61+
<_TripletFile>$(VcpkgInstalledDir).solutiontriplet</_TripletFile>
6262
</PropertyGroup>
6363

6464
<Target Name="WriteSolutionTripletToFile"
@@ -67,9 +67,19 @@
6767
<WriteLinesToFile File="$(_TripletFile)" Lines="$(VcpkgTriplet)" Overwrite="true" />
6868
</Target>
6969

70+
<!-- Note: Visual Studio does not build the .sln in the same way that MSBuild.exe does, so the above target is not executed.
71+
In that case we try to write the file on the first project we build.
72+
There is a race condition for parallel builds in doing this, but it won't happen on pipeline builds... -->
73+
<Target Name="WriteProjectTripletToFile"
74+
BeforeTargets="EnsureNoTripletMismatch"
75+
Condition="!Exists('$(_TripletFile)')">
76+
<WriteLinesToFile File="$(_TripletFile)" Lines="$(VcpkgTriplet)" Overwrite="true" />
77+
</Target>
78+
7079
<Target Name="EnsureNoTripletMismatch"
7180
BeforeTargets="PrepareForBuild"
7281
Condition="'$(_IsBuildingSln)' != 'true'" >
82+
7383
<ReadLinesFromFile File="$(_TripletFile)">
7484
<Output TaskParameter="Lines" ItemName="_TripletFileLines" />
7585
</ReadLinesFromFile>
@@ -79,6 +89,6 @@
7989
</PropertyGroup>
8090

8191
<Error Condition=" '$(_SolutionTriplet)' != '$(VcpkgTriplet)' "
82-
Text="The vcpkg triplet $(VcpkgTriplet) selected for this project does not match the solution triplet $(_SolutionTriplet)" />
92+
Text="The vcpkg triplet '$(VcpkgTriplet)' selected for project '$(MSBuildProjectName)' does not match with the solution triplet '$(_SolutionTriplet)'. If you are building from Visual Studio, try deleting the file '$(_TripletFile)'." />
8393
</Target>
8494
</Project>

0 commit comments

Comments
 (0)