Skip to content

Commit ad2a56a

Browse files
author
Carsten Igel
committed
fix: Only unregister if registration has been performed previously
As there is no satisfying ability in msbuild to test if the TLB is registered previously, we will try to rely on a touch file.
1 parent 9f275dc commit ad2a56a

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/dscom.build/dSPACE.Runtime.InteropServices.BuildTasks.Tools.targets

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@
117117
WorkingDirectory="$(_DsComWorkingDir)" />
118118
</Target>
119119

120+
<PropertyGroup>
121+
<_DsComRegistrationTouchFile>$(IntermediateOutputPath)DsComTlbRegister.touch</_DsComRegistrationTouchFile>
122+
</PropertyGroup>
123+
120124
<!-- Target to optionally register type library -->
121125
<Target Name="DsComExportTypeLibraryAndRegisterAssembly"
122126
DependsOnTargets="DsComExportTypeLibraryAfterBuild"
@@ -147,6 +151,12 @@
147151

148152
<Message Importance="High"
149153
Text="Type library file at '$(_DsComExportTypeLibraryTargetFile)' has been registered successfully." />
154+
<!-- Workaround: Instead of asking whether the TLB is registered using the registry, we rely on a touch file. -->
155+
<Touch AlwaysCreate="true"
156+
Files="$(_DsComRegistrationTouchFile)"
157+
ForceTouch="false" />
158+
159+
<Message Text="Touch file at '$(_DsComRegistrationTouchFile)' marks the successful registration of '$(_DsComExportTypeLibraryTargetFile)'. Do not delete this file as it will prevent the de-registration of the TLB before re-building." />
150160
</Target>
151161

152162
<!-- Target to optionally unregister type library. Should be called before removing. -->
@@ -173,6 +183,10 @@
173183
StdErrEncoding="UTF-8"
174184
StdOutEncoding="UTF-8"
175185
IgnoreExitCode="false"
176-
WorkingDirectory="$(_DsComWorkingDir)" />
186+
WorkingDirectory="$(_DsComWorkingDir)"
187+
Condition="Exists('$(_DsComRegistrationTouchFile)')" />
188+
<!-- Workaround: Instead of asking whether the TLB is registered using the registry, we rely on a touch file. -->
189+
<Delete Files="'$(_DsComRegistrationTouchFile)'"
190+
Condition="Exists('$(_DsComRegistrationTouchFile)')" />
177191
</Target>
178192
</Project>

0 commit comments

Comments
 (0)