Location>code7788 >text

AvaloniaUI project offline development strategy: IDE installation, template application and NuGet private deployment one-stop solution!

Popularity:946 ℃/2024-10-28 23:39:06

1. Introduction

Developing .NET projects (the example in this article is the Avalonia UI project) in a network-restricted or completely offline environment can be challenging. This article will provide you with a complete solution for offline development, including IDE installation, configuration of Avalonia UI templates, deployment of the privatized NuGet service, and creation and uploading of NuGet packages.

2. IDE Installation Guide

Visual Studio 2022 Installation

Visual Studio 2022 is the latest IDE from Microsoft that supports the development of Avalonia UI projects. Here are the detailed steps for offline installation:

  • Offline installation package creation: First, according to NetflixVS2022 Offline Installer s guide to making an offline installer for Visual Studio 2022.
  • Avalonia UI extension installation: After installing Visual Studio, pass theVisual Studio Marketplace Download and install the Avalonia for Visual Studio 2022 extension.

  • Failure encountered during installation

According to @rabbitism's answer in WeChat (thanks to @daidai_cn for the help), we can unzip the extension file and remove the box belowfile before installing it:

It's installed properly:

JetBrains Rider Installation

JetBrains Rider The IDE begins built-in support for Avalonia XAML in version 2020.3, including first-class support for Avalonia-specific XAML features and custom code inspections.

Offline installer download address:Download Rider: Cross-Platform .NET IDE ()

3. Installation of Avalonia UI templates

For online installation, please refer to the documentationAvalonia DocsFor offline installation, please click Download:

Installation as above.NET CLIcommand script:

dotnet new install .11.0.10.

You can now use Avalonia UI templates to create new projects in either Visual Studio or JetBrains Rider.

Avalonia UI template in VS 2022:

Templates are used in Rider:

4. Privatized deployment of NuGet services

After creating the project, the program is also unable to run normally, the default template relies on some NuGet packages of Avalonia UI, which need to be installed online, you can copy the related libraries directly to the intranet, but it is still troublesome to copy and reference them one by one.

To facilitate the sharing and management of NuGet packages among internal team members, you may consider deploying a private NuGet service. This article recommends using BaGet as a lightweight NuGet server, refer to thisBaGet Project Description

  1. mounting.NET Core 3.1 SDK, the program can support the latest version of .NET, interested in Clone to modify to the.NET 8\9(There are surprises in PR, and there are PR upgrade branches on the net);
  2. Download the latest Release zipReleases · loic-sharma/BaGet
  3. Operational servicesdotnet
  4. browser openshttp://localhost:5000Access:

OK, that's deployment complete.

5. NuGet package production (may be omitted)

There are more online tutorials, you can simply configure the library's project file to support NuGet package generation, refer to the

<Project>
	<PropertyGroup>
		<Company></Company>
		<Authors>Wolves at the end of the desert</Authors>
		<Owners></Owners>
		<AssemblyVersion>$(Version)</AssemblyVersion>
		<FileVersion>$(Version)</FileVersion>
		<Version>$(Version)</Version>
		<Description>pass (a bill or inspection etc) offered event bus,We can easily implement CQRS paradigm。Based on business requirements,We can create and maintain read models,Separate read and write operations,This improves the scalability and performance of the application.。Can be used in various template projects:WPF、Winform、AvaloniaUI、 Coreet al. (and other authors)。The allows us to easily implement the CQRS mode. According to business requirements, we can create and maintain a read model to separate read and write operations, thereby improving the scalability and performance of the application. Can be used in various template projects: WPF, Winform, AvaloniaUI, ASP. NET Core, etc.</Description>
		<ApplicationIcon>Resources\</ApplicationIcon>
		<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
		<Title>$(AssemblyName)</Title>
		<Copyright>Copyright © 2024</Copyright>
		<AssemblyName>$(AssemblyName)</AssemblyName>
		<RootNamespace>$(AssemblyName)</RootNamespace>
		<PackageId>$(AssemblyName)</PackageId>
		<PackageTags>C# EventBus; WPF; Winform; AvaloniaUI, Core;</PackageTags>
		<PackageIcon></PackageIcon>
		<PackageProjectUrl>/dotnet9/</PackageProjectUrl>
		<RepositoryUrl>/dotnet9/</RepositoryUrl>
	</PropertyGroup>
	<ItemGroup>
		<None Include="Resources\">
			<Pack>True</Pack>
			<PackagePath>\</PackagePath>
		</None>
	</ItemGroup>
</Project>

The corresponding NuGet file is generated when the library project is generated, here is the address of the published NuGet package:/packages/

6. NuGet package upload

You can upload NuGet packages that you have made yourself, or you can upload packages from theNuGet official website or NuGet packages obtained by third parties.

We open the NuGet home page of our own deploymenthttp://localhost:5000:

strike (on the keyboard)Upload a packageThe switch to NuGet package upload command describes.

We are based on.NET CLITo upload a NuGet package example, first prepare the NuGet file, for example from theNuGet official website searchDownload the base package for Avalonia UI:

Once downloaded, open CMD command line input in the current download directory:

dotnet nuget push -s http://localhost:5000/v3/ avalonia.11.1.

The above prompts the NuGet service to configure the key, we will stop the NuGet service first for simplicity and open its configuration fileClearApiKeynode value and then run the NuGet service:

Execute the upload command again and now it works:

The NuGet home page is now searchable as well:

7. IDE configuration NuGet source

Copy the URL address in red font from the previous NuGet upload page image:http://localhost:5000/v3/, configure the NuGet search address in VS:

The rest is consistent with the usual installation package.

Trivia: Individual ad-hoc development can configure the source above as a local NuGet directory path.

8. Summary

This article describes how to successfully install and configure the development tools and templates required for AvaloniaUI in a local network environment, as well as how to deploy a private NuGet service and create and upload NuGet packages for sharing and managing NuGet packages among members of your team.

I hope this information will help you with your AvaloniaUI project development. If you have any other questions, please feel free to ask me.