|
5 | 5 | COM servers must define a framework to use in situations where a CLR instance is not already present in the process. |
6 | 6 | Note that since the COM server may be activated in a process where the CLR must be activated, both the projects |
7 | 7 | *.runtimeconfig.json and *.deps.json files must be bundled with the server itself. |
8 | | - |
| 8 | +
|
9 | 9 | In the following example, the following files are needed to deploy the COM server: |
10 | 10 | COMServer.comhost.dll |
11 | 11 | COMServer.dll |
12 | 12 | COMServer.deps.json |
13 | 13 | COMServer.runtimeconfig.json |
| 14 | +
|
| 15 | + In a RegFree COM scenario, the following file must also be deployed: |
| 16 | + COMServer.X.manifest |
14 | 17 | --> |
15 | 18 | <TargetFramework>netcoreapp3.0</TargetFramework> |
16 | | - |
| 19 | + |
17 | 20 | <!-- Indicate the assembly is providing a COM server --> |
18 | 21 | <UseComHost>True</UseComHost> |
| 22 | + |
| 23 | + <!-- Generate a RegFree COM manifest --> |
| 24 | + <EnableRegFreeCom Condition="'$(RegFree)' == 'True'">True</EnableRegFreeCom> |
19 | 25 | </PropertyGroup> |
20 | 26 |
|
21 | 27 | <ItemGroup> |
|
24 | 30 | </ItemGroup> |
25 | 31 |
|
26 | 32 | <Target Name="ServerUsage" |
| 33 | + Condition="'$(RegFree)' != 'True'" |
27 | 34 | AfterTargets="Build"> |
28 | 35 | <Message Importance="High" Text="%0a************************************%0a*** $(MSBuildProjectName) usage instructions ***%0a************************************" /> |
29 | 36 | <Message Importance="High" Text="The server must be COM registered in order to activate.%0aThe following commands must be executed from an elevated command prompt." /> |
30 | 37 | <Message Importance="High" Text="Register:%0a regsvr32.exe "$(ProjectDir)$(OutputPath)$(ComHostFileName)"" /> |
31 | 38 | <Message Importance="High" Text="Unregister:%0a regsvr32.exe /u "$(ProjectDir)$(OutputPath)$(ComHostFileName)"" /> |
32 | 39 | </Target> |
33 | 40 |
|
| 41 | + <Target Name="ServerUsage_RegFree" |
| 42 | + Condition="'$(RegFree)' == 'True'" |
| 43 | + AfterTargets="Build"> |
| 44 | + <Message Importance="High" Text="%0a************************************%0a*** $(MSBuildProjectName) usage instructions ***%0a************************************" /> |
| 45 | + <Message Importance="High" Text="A RegFree COM manifest has been created for the server.%0aThe manifest '@(RegFreeComManifest->'%(Filename)%(Extension)')' must be included during server deployment.%0aThe COMServer project will copy all required outputs to the COMClient output directory." /> |
| 46 | + |
| 47 | + <ItemGroup> |
| 48 | + <ServerOutput Include="$(OutputPath)*.dll" /> |
| 49 | + <ServerOutput Include="$(OutputPath)*.runtimeconfig.json" /> |
| 50 | + <ServerOutput Include="$(OutputPath)*.deps.json" /> |
| 51 | + <ServerOutput Include="$(OutputPath)*.manifest" /> |
| 52 | + </ItemGroup> |
| 53 | + |
| 54 | + <!-- Deploy all required server outputs --> |
| 55 | + <Copy SourceFiles="@(ServerOutput)" |
| 56 | + DestinationFolder="../COMClient/$(OutputPath)" /> |
| 57 | + </Target> |
| 58 | + |
| 59 | + <Target Name="Clean_RegFree" |
| 60 | + AfterTargets="Clean"> |
| 61 | + <ItemGroup> |
| 62 | + <ServerOutputToDelete Include="../COMClient/$(OutputPath)COMServer.*" /> |
| 63 | + </ItemGroup> |
| 64 | + |
| 65 | + <!-- Cleanup deployed server outputs --> |
| 66 | + <Delete Files="@(ServerOutputToDelete)" /> |
| 67 | + </Target> |
| 68 | + |
34 | 69 | </Project> |
0 commit comments