【问题标题】:Make dotnet publish use dependencies from bin folder and not from nuget cache使 dotnet publish 使用来自 bin 文件夹而不是来自 nuget 缓存的依赖项
【发布时间】:2021-07-29 01:42:12
【问题描述】:

在我的 CI 中,我在不同阶段构建和发布 .net 应用程序。

在构建阶段,我执行dotnet build,它会创建objbin 文件夹。然后我将这两个文件夹传递给发布阶段并运行dotnet publish -o pub --no-build,但 msbuild 尝试从 nuget 缓存文件夹 (.nuget/packages) 而不是从bin 复制依赖项。

有没有办法让dotnet publish 使用来自bin 文件夹的依赖项?我不想从第一阶段传递整个.nuget 文件夹,因为所有依赖项都已经存储在bin 中。

【问题讨论】:

    标签: c# .net msbuild dotnet-cli


    【解决方案1】:

    我可以问一下,当dotnet publish 默认在后台构建时,为什么需要显式的dotnet build?也许this 可以帮忙?

    如果包缓存的一致性是目标,另一种方法是显式执行dotnet restore(甚至可能执行到代理临时文件夹),然后在dotnet builddotnet restore 中使用该包缓存。

    dotnet restore app\app.csproj
    dotnet build app\app.csproj --no-restore
    dotnet publish app\app.csproj -o pub --no-restore
    

    【讨论】:

      猜你喜欢
      • 2018-02-08
      • 2022-01-06
      • 1970-01-01
      • 1970-01-01
      • 2020-05-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-06
      相关资源
      最近更新 更多