-
Notifications
You must be signed in to change notification settings - Fork 37
Donet CLI
CLI tools are deprecated in Core 3.0. This section is for the new mechanics around global and local tools in Core 3.0. The standard way of injecting your events to your javascripts is to use the eventproxy by configuring it from your Startup.cs and then include it on your page. The downside of this is that its runtime only. So you will not benefit from code completion etc. We have created a Dot net Core Global/Local tool you can use.
It requires you to point out the project that holds the IEventTypeFinder, if you have this located inside your MVC Core project its good to move it out to a separate project. If it remains inside the MVC Core project it can cripple your build times because we will need to reference all dependencies to generate the output. Though if you supply it with the IEventTypeFinder type in the arguments it should be fast even for a fairly large project since it will only scan for that specific type and then use it to get all event types.
First add the tool-manifest dotnet-tools.json
file to the root of your webproject if not present. Edit the file, be sure to use the latest version, at the time of writing 5.2.268.
{
"isRoot": true,
"tools": {
"SignalR.EventAggregatorProxy.AspNetCore.GlobalTool": {
"version": "5.2.268",
"commands": [
"SignalR.EventAggregatorProxy.AspNetCore.GlobalTool"
]
}
}
}
<Target Name="BuildContracts" AfterTargets="Build">
<Exec Command="dotnet tool restore --ignore-failed-sources" />
<Exec Command="dotnet SignalR.EventAggregatorProxy.AspNetCore.GlobalTool $(OutputPath)SignalR.EventAggregatorProxy.Demo.AspNetCore.dll $(MSBuildProjectDirectory)\wwwroot\js\events.js SignalR.EventAggregatorProxy.Demo.AspNetCore.EventTypeFinder" />
</Target>
First argument points out the dll that holds the IEventTypeFinder second argument points to were you want the output to be generated. There is a third optional argument that points out the type name of the IEventTypeFinder, if you have several or if you want to speed up searching for the type in a large project dll. If you do not supply typefinder its possible the library needs to search your entire project and load dependencies etc.
Do not forget to include the output script
<script src="/js/events.js" asp-append-version="true"></script>
The standard way of injecting your events to your javascripts is to use the eventproxy by configuring it from your Startup.cs and then include it on your page. The downside of this is that its runtime only. So you will not benefit from code completion etc. We have created a Dot net core CLI project you can use.
It requires you to point out the project that holds the IEventTypeFinder, if you have this located inside your MVC Core project its good to move it out to a separate project. If it remains inside the MVC Core project it will cripple your build times because we will need to reference all dependencies to generate the output.
Edit your csproj file. You need to add the cli tool. This is done by adding it as a dependency
<DotNetCliToolReference Include="SignalR.EventAggregatorProxy.AspNetCore.DotnetCli" Version="2.0.211" />
Make sure it points to the latest version, at the time of writing 2.0.211
You also need to add a target that generates the output
<Target Name="BuildContracts" AfterTargets="Build">
<Exec Command="dotnet signalreventproxy $(OutputPath)SignalR.EventAggregatorProxy.Demo.AspNetCore.EventFinder.dll $(MSBuildProjectDirectory)\wwwroot\js\events.js" />
</Target>
First argument points out the dll that holds the IEventTypeFinder second argument points to were you want the output to be generated. There is a third optional argument that points out the type name of the IEventTypeFinder, if you have several.
Dont forget to include the output script
<script src="/js/events.js" asp-append-version="true"></script>