简体   繁体   English

使用 git 时,我可以忽略 .Net 解决方案中的特定项目吗?

[英]Can I ignore a specific project in a .Net solution when using git?

I have a .Net solution with multiple projects, for example, project A , B and C .我有一个包含多个项目的 .Net 解决方案,例如,项目ABC

B and C are dependencies of A . BCA依赖项。 That means without A , B and C could be compiled as well.这意味着没有ABC也可以编译。

There are some special configurations in project A , so I want to exclude project A when uploading to Github repository.项目A有一些特殊的配置,所以上传到Github仓库的时候想排除项目A

If I just set the project folder name in .gitignore then I will get error while compiling the solution from Git.如果我只是在.gitignore设置项目文件夹名称,那么在从 Git 编译解决方案时会出错。 What should I do?我该怎么办?

You can organize the projects in one folder each one and ignore the folder.您可以将项目组织在一个文件夹中,而忽略该文件夹。 On the .gitignore file:.gitignore文件上:

/Project.Web/*

Considering the directory Project.Web is ion the root of the repository, everything under the Project.Web path would be ignored.考虑到Project.Web目录是存储库的根目录, Project.Web路径下的所有内容都将被忽略。

Potential Problems:潜在问题:

  1. If your solution file .sln references a project that may be not exists on the structure如果您的解决方案文件.sln引用了结构上可能不存在的项目

  2. You could not be able to compile until you remove it from the sln.在将其从 sln 中删除之前,您无法进行编译。

  3. It also could be a reference to other projects in the same solution which also could avoid to compile.它也可以是对同一解决方案中其他项目的引用,也可以避免编译。

If you just want to make possible the compilation, generate the dependent assembly you want to ignore and switch the reference from the project in solution to the generated assembly.如果您只想使编译成为可能,请生成要忽略的依赖程序集,并将解决方案中的项目的引用切换到生成的程序集。 It will make the compilation possible and you will not be exposing your code.它将使编译成为可能,并且您不会暴露您的代码。

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

相关问题 我可以在同一Visual Studio解决方案中使用.NET 4和.NET 4.5吗(使用Entity Framework时)? - Can I target .NET 4 and .NET 4.5 in the same Visual Studio solution (when using Entity Framework)? 在.NET Core解决方案中使用多个项目时出现Cors问题 - Cors issue when using multiple project in .net core solution 将 Web 应用项目添加到我的解决方案中,并且解决方案中的其他项目已经使用 .net 框架,我可以将 .net 核心用于新项目吗? - adding a web app project to my solution, and the other projects in the solution already use .net framework, can I use .net core for the new project? 我可以在同一解决方案中使用.NET Framework 4.5.2和4.6.2的另一个项目吗? - Can I have a project which uses .NET Framework 4.5.2 and another project with 4.6.2 in the same solution? .NET Git忽略空格 - .NET Git ignore whitespace 要忽略的Git .Net文件 - Git .Net files to ignore 使用 DataContractSerializer 进行序列化时如何忽略属性? - How can I ignore a property when serializing using the DataContractSerializer? 我无法在我的 .NET 托管的 Blazor 解决方案中调试客户端项目 - I can't debug into the client project in my .NET hosted Blazor solution 我应该如何使用我的.NET解决方案构建我的Git存储库? - How should I structure my Git repositories with my .NET Solution? 如何克隆.NET解决方案? - How can I clone a .NET solution?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM