简体   繁体   English

将 dll 引用添加到 github 上可见的 Visual Studio c# 项目

[英]Adding dll reference to visual studio c# project visible on github

I added a reference to a local dll on my PC.我在我的 PC 上添加了对本地 dll 的引用。 How do I make sure that it will have a local reference so that when i upload to github, anyone who opens it have also access to the dll?如何确保它具有本地引用,以便当我上传到 github 时,打开它的任何人也可以访问 dll?

I tried to copy it under a folder in my project but I could not reference it there.我试图将它复制到我项目中的一个文件夹下,但我无法在那里引用它。

You put your local dll inside the bin folder of your project and then reference it to your project and when you upload your project to GitHub it will automatically uploaded您将本地 dll 放在项目的 bin 文件夹中,然后将其引用到您的项目,当您将项目上传到 GitHub 时,它将自动上传

1.Create a folder in the solution level to store the shared libraries. 1.在解决方案级别创建一个文件夹来存储共享库。

2.Copy the dll files into it. 2.将dll文件复制到其中。

3.In VS > Solution Explorer, right-click on solution > Add > New solution folder; 3.在VS>解决方案资源管理器中,右键单击解决方案>添加>新建解决方案文件夹; Create a folder that has the same name in step 1.在步骤 1 中创建具有相同名称的文件夹。

4.Right-click on the folder we just created > Add > Exiting item; 4.在我们刚刚创建的文件夹上右击>添加>退出项; Select the dll files in step2. Select 步骤 2 中的 dll 文件。

5.Reference the dll files from the shared folder. 5.引用共享文件夹中的 dll 文件。

6.Make sure the dll files reference as a relative path in csproj file. 6.确保 dll 文件引用为 csproj 文件中的相对路径。 For instance,例如,

<Reference Include="NLog">
  <HintPath>..\Shared References\NLog.dll</HintPath>
</Reference>

Moreover, check if your gitignore setting excludes the dll files.此外,检查您的 gitignore 设置是否不包括 dll 文件。

And still, Nuget is definitely a better option.尽管如此,Nuget 绝对是一个更好的选择。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM