Skip to content

Commit affdf81

Browse files
committed
Add conditions for non-Core runtime in project file
Enhance compatibility in `CqlSdkExamples.csproj` by adding conditions to ensure specific tasks and properties are executed only when `MSBuildRuntimeType` is not 'Core'. This includes restructuring `UsingTask` elements and modifying the `ModifySources` target to prevent execution in the 'Core' environment.
1 parent 3460493 commit affdf81

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

Examples/CqlSdkExamples/CqlSdkExamples.csproj

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,16 @@
3232
</None>
3333
</ItemGroup>
3434

35-
<PropertyGroup>
35+
<!-- Code Generation -->
36+
37+
<PropertyGroup Condition="'$(MSBuildRuntimeType)' != 'Core'">
3638
<RoslynCodeTaskFactoryAssembly Condition="'$(RoslynCodeTaskFactoryAssembly)' == ''">$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll</RoslynCodeTaskFactoryAssembly>
3739
</PropertyGroup>
3840

39-
<!-- Condition="'$(Configuration)'=='Debug' And '$(MSBuildRuntimeType)' != 'Core'" -->
40-
<UsingTask TaskName="UpdateCurrentDirectoryInSource" TaskFactory="RoslynCodeTaskFactory" AssemblyFile="$(RoslynCodeTaskFactoryAssembly)">
41+
<UsingTask TaskName="UpdateCurrentDirectoryInSource"
42+
TaskFactory="RoslynCodeTaskFactory"
43+
AssemblyFile="$(RoslynCodeTaskFactoryAssembly)"
44+
Condition="'$(MSBuildRuntimeType)' != 'Core'">
4145
<Task>
4246
<Using Namespace="System" />
4347
<Using Namespace="System.IO" />
@@ -94,7 +98,10 @@
9498
</Task>
9599
</UsingTask>
96100

97-
<UsingTask TaskName="UpdateLaunchSettingsInSource" TaskFactory="RoslynCodeTaskFactory" AssemblyFile="$(RoslynCodeTaskFactoryAssembly)">
101+
<UsingTask TaskName="UpdateLaunchSettingsInSource"
102+
TaskFactory="RoslynCodeTaskFactory"
103+
AssemblyFile="$(RoslynCodeTaskFactoryAssembly)"
104+
Condition="'$(MSBuildRuntimeType)' != 'Core'">
98105
<Task>
99106
<!-- System.Memory is needed for ReadOnlySpan<> -->
100107
<Reference Include="System.Memory" />
@@ -189,17 +196,19 @@
189196
var launchSettingsJsonTextNew = JsonSerializer.Serialize(launchSettingsJsonRoot, new JsonSerializerOptions() { WriteIndented = true } );
190197
if (launchSettingsJsonText != launchSettingsJsonTextNew)
191198
File.WriteAllText(launchSettingsJsonPath, launchSettingsJsonTextNew);
192-
193199
      ]]>
194-
195200
</Code>
196201

197202
</Task>
198203
</UsingTask>
199204

200-
<Target Name="ModifySources" BeforeTargets="CoreCompile">
205+
<Target Name="ModifySources"
206+
BeforeTargets="CoreCompile"
207+
Condition="'$(MSBuildRuntimeType)' != 'Core'">
201208
<UpdateCurrentDirectoryInSource />
202209
<UpdateLaunchSettingsInSource />
203210
</Target>
204211

212+
<!-- Code Generation -->
213+
205214
</Project>

0 commit comments

Comments
 (0)