|
2 | 2 | <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
3 | 3 | <PropertyGroup Label="Vcpkg"> |
4 | 4 | <VcpkgEnableManifest>true</VcpkgEnableManifest> |
5 | | - <VcpkgInstalledDir>$(MSBuildThisFileDirectory)\vcpkg_installed</VcpkgInstalledDir> |
| 5 | + <VcpkgInstalledDir>$(MSBuildThisFileDirectory)vcpkg_installed\</VcpkgInstalledDir> |
6 | 6 | </PropertyGroup> |
7 | 7 | <PropertyGroup Label="Vcpkg" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> |
8 | 8 | <VcpkgTriplet>x64</VcpkgTriplet> |
|
58 | 58 | When building the .sln, we will write a file to indicate which triplet should be used in all projects. |
59 | 59 | Each project will later read this file to verify that it is using the same triplet. --> |
60 | 60 | <_IsBuildingSln>$(MSBuildProjectName.EndsWith('.sln'))</_IsBuildingSln> |
61 | | - <_TripletFile>$(VcpkgInstalledDir)\.solutiontriplet</_TripletFile> |
| 61 | + <_TripletFile>$(VcpkgInstalledDir).solutiontriplet</_TripletFile> |
62 | 62 | </PropertyGroup> |
63 | 63 |
|
64 | 64 | <Target Name="WriteSolutionTripletToFile" |
|
67 | 67 | <WriteLinesToFile File="$(_TripletFile)" Lines="$(VcpkgTriplet)" Overwrite="true" /> |
68 | 68 | </Target> |
69 | 69 |
|
| 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 | + |
70 | 79 | <Target Name="EnsureNoTripletMismatch" |
71 | 80 | BeforeTargets="PrepareForBuild" |
72 | 81 | Condition="'$(_IsBuildingSln)' != 'true'" > |
| 82 | + |
73 | 83 | <ReadLinesFromFile File="$(_TripletFile)"> |
74 | 84 | <Output TaskParameter="Lines" ItemName="_TripletFileLines" /> |
75 | 85 | </ReadLinesFromFile> |
|
79 | 89 | </PropertyGroup> |
80 | 90 |
|
81 | 91 | <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)'." /> |
83 | 93 | </Target> |
84 | 94 | </Project> |
0 commit comments