Skip to content

Commit a0b12d7

Browse files
authored
Fix race condition on Nuget build (#2930)
- nodeset xmlzip is created in obj folders if multiple targets are built in parallel
1 parent 8d234e2 commit a0b12d7

File tree

2 files changed

+23
-14
lines changed

2 files changed

+23
-14
lines changed

Stack/Opc.Ua.Core/Opc.Ua.Core.csproj

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<Description>OPC UA Core Class Library</Description>
1010
<IsPackable>true</IsPackable>
1111
<GenerateDocumentationFile>true</GenerateDocumentationFile>
12+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
1213
</PropertyGroup>
1314

1415
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
@@ -88,23 +89,31 @@
8889

8990
<Target Name="GetPackagingOutputs" />
9091

91-
<!-- Produces a zipped version of the Nodeset 2 to reduce assembly size by 2.7MB ! -->
92-
<ItemGroup>
93-
<EmbeddedResource Include="Schema\Opc.Ua.NodeSet2.xml.zip" />
94-
</ItemGroup>
95-
92+
<!-- Produces a zipped version of the Nodeset 2 to reduce assembly size! -->
9693
<PropertyGroup>
97-
<ZipTmp>$(BaseIntermediateOutputPath)/zipnodeset2</ZipTmp>
98-
<ZipNodeSet2XML>Schema/Opc.Ua.NodeSet2.xml</ZipNodeSet2XML>
99-
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
94+
<ZipTmp>$(BaseIntermediateOutputPath)$(Configuration)/$(TargetFramework)/zipnodeset2</ZipTmp>
95+
<NodeSet2XML>Schema/Opc.Ua.NodeSet2.xml</NodeSet2XML>
96+
<ZipNodeSet2XML>$(BaseIntermediateOutputPath)$(Configuration)/$(TargetFramework)/Opc.Ua.NodeSet2.xml.zip</ZipNodeSet2XML>
10097
</PropertyGroup>
10198

102-
<Target Name="ZipNodeSet2" BeforeTargets="PrepareForBuild" Inputs="$(ZipNodeSet2XML)" Outputs="$(ZipNodeSet2XML).zip">
103-
<Message Text="Zip $(ZipNodeSet2XML) in $(ZipTmp)." Importance="high" />
104-
<Copy SourceFiles="$(ZipNodeSet2XML)" DestinationFolder="$(ZipTmp)" />
105-
<ZipDirectory SourceDirectory="$(ZipTmp)" DestinationFile="$(ZipNodeSet2XML).zip" Overwrite="true" />
99+
<!-- Embed the zipped Nodeset2 file -->
100+
<ItemGroup>
101+
<EmbeddedResource Include="$(ZipNodeSet2XML)" Link="$(NodeSet2XML).zip" />
102+
</ItemGroup>
103+
104+
<!-- Zip the NodeSet2 file -->
105+
<Target Name="ZipNodeSet2" BeforeTargets="PrepareForBuild" Inputs="$(NodeSet2XML)" Outputs="$(ZipNodeSet2XML)">
106+
<Message Text="Zip $(NodeSet2XML) in $(ZipNodeSet2XML)." Importance="high" />
107+
<Copy SourceFiles="$(NodeSet2XML)" DestinationFolder="$(ZipTmp)" />
108+
<ZipDirectory SourceDirectory="$(ZipTmp)" DestinationFile="$(ZipNodeSet2XML)" Overwrite="true" />
106109
<RemoveDir Directories="$(ZipTmp)" />
107110
<Message Text="Zip NodeSet2 completed, $(ZipTmp) removed." Importance="high" />
108111
</Target>
109-
112+
113+
<!-- Clean up the zip file -->
114+
<Target Name="RemoveZipNodeset2" AfterTargets="Clean" Condition="Exists('$(ZipNodeSet2XML)')">
115+
<Message Text="Delete Zip $(ZipNodeSet2XML)" Importance="high"></Message>
116+
<Delete Files="$(ZipNodeSet2XML)"></Delete>
117+
</Target>
118+
110119
</Project>

azure-pipelines.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ stages:
6868
parameters:
6969
configuration: Release
7070
framework: net6.0
71-
agents: '@{ windows = "windows-2022"; linux="ubuntu-22.04"; mac = "macOS-12"}'
71+
agents: '@{ windows = "windows-2022"; linux="ubuntu-22.04"; mac = "macOS-15"}'
7272
jobnamesuffix: net60
7373
customtestarget: net6.0
7474
- stage: testreleasepr

0 commit comments

Comments
 (0)