[英]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 解决方案,例如,项目
A
、 B
和C
。
B
and C
are dependencies of A
. B
和C
是A
依赖项。 That means without A
, B
and C
could be compiled as well.这意味着没有
A
, B
和C
也可以编译。
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:潜在问题:
If your solution file .sln
references a project that may be not exists on the structure如果您的解决方案文件
.sln
引用了结构上可能不存在的项目
You could not be able to compile until you remove it from the sln.在将其从 sln 中删除之前,您无法进行编译。
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.