解决方案的启动项目设置存储在哪里? [英] Where is the Startup Project setting stored for a solution?

查看:42
本文介绍了解决方案的启动项目设置存储在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在解决方案资源管理器中右键单击我的解决方案并选择属性时,我会看到一个对话框,我可以在其中选择启动项目.

我有时会选择当前选择(如果它是一个实验性的解决方案,有很多项目我会在其中跳转),但大多数情况下它会选择单个启动项目,这通常是主要的 WinForms 应用程序或控制台应用程序.

我的问题是,每当我使用 tfpt 命令(Team Foundation Power Tools 2008)执行 treeclean 时,都会忘记此设置.因此,当我下次尝试运行我的解决方案时,它默认为某个随机项目,并且我收到一条错误消息,指出我无法运行类库或类似的东西.这当然是显而易见的.但是这个设置存储在哪里?为什么我清理树时会忘记它?解决方案文件还在,对吧?解决方案属性不是存储在那里吗?

解决方案

参考 1

Arian Kulp 说:

<块引用>

我一直在努力想办法为什么我的某个解决方案开始不正确.它是在 VB 中有四个项目.初次打开时它会设置一个特定的项目DLL 输出作为启动.如果我设置EXE作为启动项目,很好,但是当我分发代码时,我总是通过删除 *.suo 和 *.user 来清理它文件和 bin/obj 文件夹.之上打开清理过的"版本,它将始终恢复到 DLL 项目并没有很好地 F5.修复变了很简单,虽然我很好奇至于为什么我需要这样做.

在解决方案文件中,有一个列表伪 XML项目"条目.它原来无论是第一个一个最终成为启动项目,除非它在 ​​suo 中被覆盖文件.啊.我刚刚重新排列了在文件中订购,很好.

我猜C#也是一样的但我没有测试.我希望这对某人有帮助!

参考文献 2

设置启动项目

<块引用>

哪个项目是启动"?project 仅与调试相关,这意味着从解决方案和项目的角度来看,它是用户元数据.无论哪个项目是启动"项目,编译后的代码是一样的.

因此,该信息作为用户设置存储在解决方案文件 (solution.sln) 附带的解决方案用户选项文件 (solution.suo) 中..suo 文件记录您可能与解决方案关联的所有选项,以便每次打开它时,它都包含您所做的自定义".根据 MSDN.

.suo 文件是一个二进制文件.如果您想以编程方式阅读或更改它,您必须使用 来自 Microsoft.VisualStudio.Shell.Interop 命名空间的 IVsPersistSolutionOpts.LoadUserOptions.

When I right-click my solution in the Solution Explorer and choose Properties I get a dialog where I can select the Startup Project.

I sometimes select Current selection (If it is an experimental solution with lots of projects I jump between), but most often it is a Single startup project selected, which would usually be the main WinForms applications or or Console application.

My problem is that whenever I do a treeclean with the tfpt command (Team Foundation Power Tools 2008) this setting is forgotten. So when I try to run my solution the next time, it has defaulted to some random project and I get an error stating that I cannot run a class library or something like that. Which is obvious of course. But where is this setting stored? Why is it forgotten when I do the treeclean? The solution file is still there, right? Isn't solution properties stored there?

解决方案

Reference 1

Arian Kulp says:

I was struggling with trying to figure out why a certain solution of mine wasn’t starting right. It was in VB with four projects. Upon initial open it would set a certain project with a DLL output as startup. If I set the EXE as startup project, it was fine, but when I distribute code I always clean it by removing *.suo and *.user files, and bin/obj folders. Upon opening the "cleaned" version, it would always revert to the DLL project and fail to F5 nicely. The fix turned out to be simple, though I’m curious as to why I needed to do this at all.

In the solution file, there are a list of pseudo-XML "Project" entries. It turns out that whatever is the first one ends up as the Startup Project, unless it’s overridden in the suo file. Argh. I just rearranged the order in the file and it’s good.

I’m guessing that C# is the same way but I didn’t test it. I hope that this helps someone!

Reference 2

Setting the StartUp Project

Which project is the "startup" project only has any relevance for debugging, which means it's user metadata from the point of the solution and the projects. Regardless of which project is the "startup" project, the compiled code is the same.

Because of this, the information is stored as a user setting in the Solution User Options file (solution.suo) which accompanies the Solution file (solution.sln). The .suo file "Records all of the options that you might associate with your solution so that each time you open it, it includes customizations that you have made" according to MSDN.

The .suo file is a binary file. If you want to read or change it programatically, you have to use IVsPersistSolutionOpts.LoadUserOptions from the Microsoft.VisualStudio.Shell.Interop namespace.

这篇关于解决方案的启动项目设置存储在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆