引用第三方库
Add a third-party library to the Visual Studio Code project
Add a third-party .NET library by editing the CSPROJ project file.
Set Visual Studio Code as the default external code editor. See Set the default code editor.
1. Copy the .NET assembly for the library to the ProjectFiles/NetSolution FactoryTalk Optix Studio project folder.
2. From the main toolbar, select .The default external code editor opens.
Tip: We recommend using Microsoft Visual Studio 2022 or Microsoft Visual Studio Code as the default code editor. Some development assistance features may not be available when using a different code editor.
3. In Visual Studio Code, open the CSPROJ project file.
4. Add the following
<Reference Include="library">
<HintPath>path</HintPath>
<Private>True</Private>
</Reference>
library The library that you want to add. For example: MyLibrary path The path to the library from 1. For example: ..\MyLibrary.dll
<ItemGroup>
<Reference Include="MyLibrary">
<HintPath>..\MyLibrary.dll</HintPath>
<Private>True</Private>
</Reference>
<!-- The rest of the code -->
</ItemGroup>
- Save the CSPROJ file.
Install NuGet packages in Visual Studio Code
Install NuGet packages by using the NuGet Gallery extension. Set Visual Studio Code as the default external code editor. See Set the default code editor. 1. From the main toolbar, select .The default external code editor opens. Tip: We recommend using Microsoft Visual Studio 2022 or Microsoft Visual Studio Code as the default code editor. Some development assistance features may not be available when using a different code editor. 2. In Visual Studio Code, install the NuGet Gallery extension NuGet Gallery - Visual Studio Marketplace. 3. Open the Command Palette by pressing Ctrl > Shift > P. 4. In the Command Palette, enter nuget and select NuGet: Open NuGet Gallery. 5. Install the necessary NuGet packages. 6. In the CSPROJ file, after the
- Save the CSPROJ file.
- Compile the project.