forked from SonarSource/sonarlint-visualstudio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SonarLint.VsTargetVersion.props
53 lines (37 loc) · 2.25 KB
/
SonarLint.VsTargetVersion.props
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<Project>
<!-- This file sets the VsTargetVersion property.
It should be imported by any other props/targets/project file that needs to conditionally
modify the build based on the version of VS.
It can be conditionally imported as follows:
<Import Condition=" $(VsTargetVersionPropsImported) != 'true'" Project="[PATH](SonarLint.VsTargetVersion.props" />
Building from the command line
==============================
When building from the VS developer command line, by default the targeted version of VS will
depend on the version of the developer command prompt
i.e. building from the VS2019 developer command prompt will build for VS2019 etc.
Alternatively, you can explicitly specify the version of VS to target e.g.
msbuild.exe SonarLint.VisualStudio.Integration.sln /p:VsTargetVersion=2019
The allowed values for VsTargetVersion are 2019 and 2022.
-->
<PropertyGroup>
<!-- Flag to prevent importing this file multiple times -->
<VsTargetVersionPropsImported>true</VsTargetVersionPropsImported>
</PropertyGroup>
<!-- Set the VsTargetVersion based on the version of VS -->
<PropertyGroup Condition=" $(VsTargetVersion) == '' " >
<VsTargetVersion Condition="$(VisualStudioVersion)=='16.0'">2019</VsTargetVersion>
<VsTargetVersion Condition="$(VisualStudioVersion)=='17.0'">2022</VsTargetVersion>
</PropertyGroup>
<!-- ************************************************************* -->
<!-- Sanity check to fail the build if VsTargetVersion isn't used correctly -->
<!-- ************************************************************* -->
<Target Name="CheckVsTargetVersionSetting" BeforeTargets="PrepareForBuild">
<Error
Condition=" $(BuildingInsideVisualStudio) != 'true' AND $(VsTargetVersion) == '' "
Text="Must set VsTargetVersion build property when building outside Visual Studio. Expected values: 2019, 2022"/>
<Error
Condition=" $(VsTargetVersion) != '2019' AND $(VsTargetVersion) != '2022' "
Text="Invalid value for VsTargetVersion. Expected values: 2019, 2022. Actual value: $(VsTargetVersion)"/>
<Message Importance="high" Text="SonarLint VsTargetVersion: $(VsTargetVersion)" />
</Target>
</Project>