11<Project ToolsVersion =" 14.0" xmlns =" http://schemas.microsoft.com/developer/msbuild/2003" >
22
3- <Target Name =" GenerateInterfaces_ros2cs" BeforeTargets =" CoreCompile" >
3+ <PropertyGroup >
4+ <GenerateInterfaces_ros2csDependsOn >
5+ $(GenerateInterfaces_ros2csDependsOn);GetRos2csProps
6+ </GenerateInterfaces_ros2csDependsOn >
7+ </PropertyGroup >
48
5- < PropertyGroup Condition = " '$(Ros2csExe)' == '' " >
6- < Ros2csExe >$(MSBuildThisFileDirectory)\..\tools\net6.0\ros2cs\ros2cs.dll</ Ros2csExe >
7- </ PropertyGroup >
9+ < Target Name = " GenerateInterfaces_ros2cs " BeforeTargets = " BeforeCompile;CoreCompile "
10+ DependsOnTargets= " $(GenerateInterfaces_ros2csDependsOn) "
11+ Inputs= " $(Ros2csSpecFile) " Outputs = " $(IntermediateOutputPath)\$(Ros2csOutputDir)\ros2cs.spec.cache " >
812
9- <PropertyGroup >
10- <DefaultRos2csSpecFile >$(MSBuildProjectDirectory)\ros2cs.spec</DefaultRos2csSpecFile >
11- <Ros2csOutputDir Condition =" $(Ros2csOutputDir) == ''" >Ros2csGeneratedInterfaces</Ros2csOutputDir >
12- <Ros2csSpecFile Condition =" $(Ros2csSpecFile) == '' and Exists('$(DefaultRos2csSpecFile)')" >$(DefaultRos2csSpecFile)</Ros2csSpecFile >
13- <Ros2csCommand >dotnet " $(Ros2csExe)" -o $(IntermediateOutputPath)\$(Ros2csOutputDir) " $(Ros2csSpecFile)" </Ros2csCommand >
14- </PropertyGroup >
13+ <Message Text =" Ros2csSpec: $(Ros2csSpecFile)" />
1514
16- <Message Text =" Ros2csSpec : $(Ros2csSpecFile )" />
15+ <Message Text =" Ros2csCmd : $(Ros2csCommand )" />
1716
18- <Message Text =" Ros2csCmd: $(Ros2csCommand)" />
17+ <Exec Command =" $(Ros2csCommand)" WorkingDirectory =" $(MSBuildProjectDirectory)"
18+ ConsoleToMSBuild =" true" IgnoreExitCode =" true" Condition =" '$(Ros2csSpecFile)' != ''" >
19+
20+ <Output TaskParameter =" ConsoleOutput" ItemName =" Ros2csOutput" />
21+ <Output TaskParameter =" ExitCode" PropertyName =" Ros2csExitCode" />
22+ </Exec >
23+
24+ <Error Condition =" '$(Ros2csSpecFile)' != '' and '$(Ros2csExitCode)' != '0'"
25+ Text =" '$(Ros2csCommand)' failed with exit code $(Ros2csExitCode):
 @(Ros2csOutput->'%(Identity)', '
 ')" />
1926
20- <Exec Command =" $(Ros2csCommand)" WorkingDirectory =" $(MSBuildProjectDirectory)"
21- ConsoleToMSBuild=" true" IgnoreExitCode =" true" Condition =" '$(Ros2csSpecFile)' != ''" >
27+ <Copy SourceFiles =" $(Ros2csSpecFile)"
28+ DestinationFiles =" $(IntermediateOutputPath)\$(Ros2csOutputDir)\ros2cs.spec.cache"
29+ SkipUnchangedFiles =" true"
30+ Condition =" '$(Ros2csSpecFile)' != ''" />
31+
32+ <ItemGroup >
33+ <Compile Remove =" @(Ros2csGenFiles)" />
34+ <Compile Include =" $(IntermediateOutputPath)\$(Ros2csOutputDir)\**\*.g.cs" />
35+ </ItemGroup >
36+ </Target >
2237
23- <Output TaskParameter =" ConsoleOutput" ItemName =" Ros2csOutput" />
24- <Output TaskParameter =" ExitCode" PropertyName =" Ros2csExitCode" />
25- </Exec >
2638
27- <Error Condition =" '$(Ros2csSpecFile)' != '' and '$(Ros2csExitCode)' != '0'"
28- Text=" ros2cs failed with exit code $(Ros2csExitCode):
 @(Ros2csOutput->'%(Identity)', '
 ')" />
39+ <PropertyGroup >
40+ <CleanGenerated_ros2csDependsOn >
41+ $(CleanGenerated_ros2csDependsOn);GetRos2csProps
42+ </CleanGenerated_ros2csDependsOn >
43+ </PropertyGroup >
2944
30- <ItemGroup >
31- <Compile Remove =" @(Ros2csGenFiles)" />
32- <Compile Include =" $(IntermediateOutputPath)\$(Ros2csOutputDir)\**\*.g.cs" />
33- </ItemGroup >
34- </Target >
45+ <Target Name =" CleanGenerated_ros2cs" BeforeTargets =" CoreClean" DependsOnTargets =" $(CleanGenerated_ros2csDependsOn)" >
46+ <RemoveDir Directories =" $(IntermediateOutputPath)\$(Ros2csOutputDir)" />
47+ </Target >
3548
36- <Target Name =" CleanGenerated_ros2cs" BeforeTargets =" CoreClean" >
37- <RemoveDir Directories =" $(IntermediateOutputPath)\$(Ros2csOutputDir)" />
38- </Target >
49+
50+ <Target Name =" GetRos2csProps" DependsOnTargets =" $(GetRos2csPropsDependsOn)" >
51+ <PropertyGroup >
52+ <DefaultRos2csSpecFile >$(MSBuildProjectDirectory)\ros2cs.spec</DefaultRos2csSpecFile >
53+ <Ros2csSpecFile Condition =" $(Ros2csSpecFile) == '' and Exists('$(DefaultRos2csSpecFile)')" >$(DefaultRos2csSpecFile)</Ros2csSpecFile >
54+
55+ <Ros2csCommand >dotnet $(Ros2csExe.Trim()) $(Ros2csArgs.Trim()) -o " $(IntermediateOutputPath)\$(Ros2csOutputDir.Trim())" " $(Ros2csSpecFile.Trim())" </Ros2csCommand >
56+ </PropertyGroup >
57+ </Target >
58+
59+
60+ <Target Name =" CheckAmentPrefixPath" AfterTargets =" GetRos2csProps" >
61+ <ReadLinesFromFile File =" $(Ros2csSpecFile)" >
62+ <Output TaskParameter =" Lines" ItemName =" Ros2csSpecFileLines" />
63+ </ReadLinesFromFile >
64+
65+ <Warning Code =" RCL0002" File =" $(Ros2csSpecFile)"
66+ Condition =" '$(AMENT_PREFIX_PATH)' == '' AND @(Ros2csSpecFileLines->AnyHaveMetadataValue('Identity', 'from-ament-index'))"
67+ Text =" 'from-ament-index' option is specified in ros2cs.spec file but 'AMENT_PREFIX_PATH' Property or Environment Variable is not set/empty. ROS 2 interface packages may not be found." />
68+ </Target >
3969
4070</Project >
0 commit comments