日常生活的交流与学习

首页 新随笔 联系 管理

dotnet如何设置restore package path,依赖和项目放在一起

配置说明

再.csproj中添加如下配置,然后 dotnet restore ,可以依赖包放到和项目一起,从而方便移动到没有网络的电脑上执行

<RestorePackagesPath>../packages</RestorePackagesPath>

所需的依赖包就会复制一份到本地,如下

├─Cache
├─Config
├─CV
├─Note
├─packages 👈👈👈👈👈👈👈👈👈👈👈👈👈👈👈👈👈👈👈
└─RCS

完成配置

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>net7.0</TargetFramework>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
    <InvariantGlobalization>true</InvariantGlobalization>
    <!-- 👇👇👇👇👇👇👇👇👇👇👇👇👇👇👇👇👇👇👇-->
    <RestorePackagesPath>../packages</RestorePackagesPath>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="6.0.0" />
	  <PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="6.0.0" />
	  <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.0">
		  <PrivateAssets>all</PrivateAssets>
		  <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
	  </PackageReference>
	  <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.0" />
	  <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.0" />
	  <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="6.0.0" />
	  <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
    <PackageReference Include="NLog" Version="5.2.8" />
    <PackageReference Include="NLog.Web.AspNetCore" Version="5.3.8" />
    <PackageReference Include="Quartz" Version="3.8.0" />
    <PackageReference Include="Quartz.Extensions.DependencyInjection" Version="3.8.0" />
    <PackageReference Include="Quartz.Extensions.Hosting" Version="3.8.0" />
	  <PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
  </ItemGroup>

</Project>
posted on 2024-08-29 19:23  lazycookie  阅读(22)  评论(0编辑  收藏  举报