-
-
Notifications
You must be signed in to change notification settings - Fork 38
Compilation
PrtgAPI provides full support for .NET Core, providing target frameworks for both net452
and netstandard2.0
Due to the current poor state of .NET Core tooling however, for development PrtgAPI provides both .NET Core SDK style projects (compatible with dotnet.exe
/ Visual Studio 2017+) as well as legacy .NET Framework style projects (compatible with Visual Studio 2015+). The PrtgAPI Build Environment provides a unified interface for compiling both the SDK and legacy style solutions.
- Install Visual Studio 2017 (15.9.11) or higher with either of the following workloads
- .NET Core cross-platform development
- .NET desktop development + the .NET Framework 4.6.1 Targeting Pack component
- Open
PrtgAPIv17.sln
from the repo root - Build!
On Windows, Debug will build assemblies for netstandard2.0
, while Release will build assemblies for both net452
and netstandard2.0
. On Linux, all projects (including test projects) will build assemblies for netcoreapp2.1
. If you wish to import the netstandard2.0
assemblies in Windows PowerShell, you must have .NET Framework 4.7.1 installed.
Note: as of writing, due to the current immaturity of the .NET Core tooling, the following restrictions apply when utilizing PrtgAPIv17.sln
- When switching between Debug and Release you must close and reopen Visual Studio
- The debugger does not work when debugging under PowerShell 5.1, as Visual Studio improperly utilizes the CoreCLR debugger instead of the .NET Framework one. To debug PowerShell 5.1 you must either change the debug target framework in
Directory.Build.props
, or simply use the legacyPrtgAPI.sln
which doesn't have to deal with this nonsense
- Install Visual Studio 2015 or higher. For Visual Studio 2017+, install the .NET desktop development workload
- Open
PrtgAPI.sln
from the repo root - Right cick the
PrtgAPI
solution in Visual Studio and clickRestore Restore NuGet Packages
- Build!
To build PrtgAPI using the command line, complete the following steps
- Open
build.cmd
orbuild.sh
from the project root- Note: if you are Linux or macOS you must already have PowerShell Core installed
- Run
Invoke-PrtgBuild -SourceLink:$false
- Done!
By default, Invoke-PrtgBuild
compiles PrtgAPI with SourceLink information, for stepping into the PrtgAPI source code hosted on GitHub when debugging in Visual Studio. The SourceLink libraries are absolutely terrible however, and can be a major source of frustration when trying to compile. As such, it is recommended to always specify -SourceLink:$false
to bypass these kinds of issues.
To build the legacy .NET Framework version of PrtgAPI, specify the -Legacy
parameter
Invoke-PrtgBuild -Legacy -SourceLink:$false
When building using the .NET Core SDK, Invoke-PrtgBuild
will automatically install all dependencies required to complete the build. When building with -Legacy
, Invoke-PrtgBuild
will search for a version of MSBuild installed in Program Files or alongside Visual Studio. If MSBuild cannot be found, the build will fail.
By default, Invoke-PrtgBuild
will compile for Debug. If you wish to compile for Release, specify the -Configuration
parameter
Invoke-PrtgBuild -c Release -SourceLink:$false
In the event you wish to debug an issue with the build, you can specify the -Dbg
parameter to create a *.binlog
trace that will automatically be opened in MSBuild Structured Log Viewer when the build completes.
Invoke-PrtgBuild -Dbg -SourceLink:$false
Note that this requires you have the MSBuild Structured Log Viewer already installed and that it is your default handler for *.binlog
files. If Invoke-PrtgBuild
fails to open the *.binlog
file for you, you can find it at msbuild.binlog
in the repo root.
To clear previous PrtgAPI builds, use the Clear-PrtgBuild
cmdlet. By default Clear-PrtgBuild
will attempt to perform a standard MSBuild clear of your solution. If you wish to force a clear however (i.e. literally go through and force delete all temporary build files) you can specify the -Full
parameter
Clear-PrtgBuild -Full