【问题标题】:Shared C# components to be used in another application from 2 different GIT Repositories要在来自 2 个不同 GIT 存储库的另一个应用程序中使用的共享 C# 组件
【发布时间】:2021-04-29 11:29:08
【问题描述】:

基本上我有一个通用应用程序(跨多个系统使用)然后我有单独的 dll,它们保存在主应用程序的不同解决方案中。在某些情况下,单个 dll 将包含对主应用程序中某些组件的引用。

我想将主应用程序的解决方案存储在与其他解决方案不同的 Git 存储库中。

我怎样才能拥有 2 个存储库,而其中一个存储库使用另一个存储库的组件?

【问题讨论】:

  • 询问“什么是 X 的最佳方法”是一种非常安全的关闭方式,因为它是基于意见的。您可能想要编辑您的问题,它会解释您遇到的 problem 以及您想问的 question,因此对它的回答将解决您的问题。在您的情况下,可能会以“我如何...”开始

标签: c# git nuget


【解决方案1】:

一个 NuGet 库将是要走的路。但是,正确设置它可能需要做很多工作。

更脏的方法是创建一个 CMD 脚本,它将克隆 repo、复制文件并将其包含在您的项目中。 它可能看起来像这样。

echo Make sure to close your IDE or any other programs that have any file in the source or bin folder open.

:: delete source files
del source /q
del bin /q

mkdir source
cd source

:: clone new source files
git clone https://github.com/your_repo

:: go back to root
cd ../

:: build source files
dotnet build source\path_to.csproj --configuration production --output bin/ProjectName

pause

然后将 dll 作为解决方案项包含在内,并将其作为 dll 引用包含在您的项目中

<Reference Include="your_project_name">
  <HintPath>..\path_to_dll_you_just_build.dll</HintPath>
</Reference>

【讨论】:

  • 您最好先克隆,然后再获取。但这也有效。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-05-08
  • 1970-01-01
  • 2019-01-21
  • 2016-05-23
  • 2011-08-07
  • 1970-01-01
  • 2011-03-21
相关资源
最近更新 更多