-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathServiceControl.Management.PowerShell.csproj
More file actions
93 lines (80 loc) · 4.84 KB
/
ServiceControl.Management.PowerShell.csproj
File metadata and controls
93 lines (80 loc) · 4.84 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<Project Sdk="Microsoft.NET.Sdk">
<!--
NOTE: No ProjectReferences or PackageReferences can be added to the project without first ensuring that they done in a way that
doesn't break the dependency isolation required by the PowerShell module. All dependencies need to be loaded in the separated
AssemblyLoadContext so that they don't conflict with the assemblies that ship as part of PowerShell itself or from other modules.
Additionally, any type that lives in a dependency can mess up the module loading process if it's exposed as part of the public API
of the PowerShell cmdlets. It's complex. Tread carefully.
See: https://devblogs.microsoft.com/powershell/resolving-powershell-module-assembly-dependency-conflicts/
-->
<PropertyGroup>
<!-- Must stay net8.0 to support PowerShell 7.4 LTS -->
<TargetFramework>net8.0-windows</TargetFramework>
<!--Ensures that all project references are explicitly defined in this file -->
<DisableTransitiveProjectReferences>true</DisableTransitiveProjectReferences>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\ServiceControlInstaller.Engine\ServiceControlInstaller.Engine.csproj" Private="false" />
<!--Even though we have this dependency, we are actually relying on the copy provided by ServiceControlInstaller.Engine at runtime -->
<ProjectReference Include="..\ServiceControl.LicenseManagement\ServiceControl.LicenseManagement.csproj" Private="false" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyModel" GeneratePathProperty="true" VersionOverride="8.0.2" />
<PackageReference Include="System.Management.Automation" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Particular.Obsoletes" PrivateAssets="All" ExcludeAssets="runtime" />
</ItemGroup>
<ItemGroup>
<Artifact Include="$(OutputPath)" DestinationFolder="$(PowerShellModuleArtifactsPath)" />
<Artifact Include="$(PkgMicrosoft_Extensions_DependencyModel)\lib\net8.0\Microsoft.Extensions.DependencyModel.dll" DestinationFolder="$(PowerShellModuleArtifactsPath)" />
<Artifact Include="$(PowerShellModuleName).psd1" DestinationFolder="$(PowerShellModuleArtifactsPath)" />
<Artifact Include="$(PowerShellModuleName).psm1" DestinationFolder="$(PowerShellModuleArtifactsPath)" />
<Artifact Include="$(PowerShellModuleName).format.ps1xml" DestinationFolder="$(PowerShellModuleArtifactsPath)" />
<Artifact Include="ServiceControl.Management.PowerShell.dll-help.xml" DestinationFolder="$(PowerShellModuleArtifactsPath)" />
</ItemGroup>
<UsingTask TaskName="FileUpdate" TaskFactory="RoslynCodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll">
<ParameterGroup>
<Files ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="true" />
<Pattern ParameterType="System.String" Required="true" />
<ReplacementText ParameterType="System.String" />
</ParameterGroup>
<Task>
<Using Namespace="System.Text.RegularExpressions" />
<Using Namespace="System.IO" />
<Code Type="Fragment" Language="cs">
<![CDATA[
RegexOptions options = RegexOptions.Multiline | RegexOptions.IgnoreCase;
if (Files.Length > 0)
{
ReplacementText ??= string.Empty;
if (Pattern == "{{Prerelease}}" && !string.IsNullOrEmpty(ReplacementText))
{
var parts = ReplacementText.Split('.');
var result = int.Parse(parts[1]);
ReplacementText = $"{parts[0]}{result:D4}";
}
for (int i = 0; i < Files.Length; i++)
{
var path = Files[i].GetMetadata("FullPath");
File.WriteAllText(path, Regex.Replace(File.ReadAllText(path), Pattern, ReplacementText, options));
}
}
]]>
</Code>
</Task>
</UsingTask>
<Target Name="UpdateModuleManifestVersion" DependsOnTargets="MinVer" AfterTargets="CopyArtifacts">
<ItemGroup>
<ModuleFile Include="$(PowerShellModuleArtifactsPath)$(PowerShellModuleName).psd1" />
</ItemGroup>
<FileUpdate Files="@(ModuleFile)" Pattern="{{Version}}" ReplacementText="$(MinVerMajor).$(MinVerMinor).$(MinVerPatch)" />
<FileUpdate Files="@(ModuleFile)" Pattern="{{Prerelease}}" ReplacementText="$(MinVerPrerelease)" />
<FileUpdate Files="@(ModuleFile)" Pattern="{{Date}}" ReplacementText="$([System.DateTime]::UtcNow.ToString(yyyy))" />
</Target>
<Target Name="WorkaroundForSqlClientWindowsFormsReference" BeforeTargets="AddTransitiveFrameworkReferences">
<ItemGroup>
<TransitiveFrameworkReference Remove="@(TransitiveFrameworkReference)" Condition="'%(TransitiveFrameworkReference.Identity)' == 'Microsoft.WindowsDesktop.App.WindowsForms'" />
</ItemGroup>
</Target>
</Project>