Automate Everything

关于自动化相关的任何东西,包括自动化测试,Visual Studio宏, 自动化安装部署等

Archive for the ‘VS2005’ Category

你是否知道- 你可以在Object Browser中直接添加References

星期四, 05月 8th, 2008

转自:

Did you know… You can add references to your solution directly from the Object Browser - #210

一般我们添加Reference都是通过打开Sulution Explorer,在Reference文件夹或者Project节点上点击右键,选择添加引用,然后在添加引用的对话框里边选择引用。

让我们看看其它的方法怎么做: 在Object Browser的工具栏上有一个按钮叫做‘Add To References’

 ObjectBrowserAddReference_6

然后你可以看到’Accessibility’已经被添加到了工程中

ObjectBrowserAddReference2_2

把这篇文章分享到: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • del.icio.us
  • bodytext
  • Google
  • Facebook
  • Furl

你是否知道-怎么从命令行编译(build)一个解决方案(Solution)

星期一, 04月 14th, 2008

转载自:Did you know… How to build a solution from the command line

建议使用Visual Studio 2005 Command Prompt来运行所有的命令
你可以从开始菜单-> 所有程序 –> Microsoft Visual Studio 2005 –> Visual Studio Tools来运行Visual Studio 2005 Command Prompt,这样你就不需要担心怎么设置正确的环境变量,比如PATH

试试输入Devenv /?
从命令行的输出,你可以看到这个命令的帮助,你需要用这些来进行编译

在命令行的帮助,你可以看到这个示例:
devenv solutionfile.sln /build solutionconfig [ /project projectnameorfile [ /projectconfig name ] ]

上边的命令可以简化为:
devenv <solutionname> /build

你同样可以制定解决方案(Solution)的配置和工程配置。你可以使用Build->Configuration Manager来创建一个新的工程和解决方案的配置来进行编译。例如:
devenv <solutionname> /build "Debug|Any CPU" /project <projectname> /projectconfig “Debug|Any CPU”

最后一点,你可以指定将编译的日志写在什么地方:
devenv <solutionname> /build "Debug|Any CPU" /project <projectname> /projectconfig “Debug:Any CPU” /out <filename>

把这篇文章分享到: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • del.icio.us
  • bodytext
  • Google
  • Facebook
  • Furl

你是否知道-你可以调整‘自动完成’(Statement Completion)窗口的大小

星期一, 04月 14th, 2008

转载自:Did you know… you can resize the statement completion window? - #059

是的,你可以往任意方向调整‘自动完成’窗口的大小:

注:

  • 最大高度:1/3屏幕高度
把这篇文章分享到: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • del.icio.us
  • bodytext
  • Google
  • Facebook
  • Furl

你是否知道-VisualStudio中怎么使用工程模板

星期一, 04月 14th, 2008

转载自:Did you know… How to use Project Templates

什么是工程模板(Project Templates)?

工程模板就是一个简单的工程,你可以使用它创建一个新的工程,比如:Windows Applications, Class Libraries, WebSites等等。对Visual Studio2005 (开发代号Whidbey)中,模板作为一个单独Zip文件存储在硬盘上。Visual Studio会默认安装一些模板在:<Program Files>\Microsoft Visual Studio 8\Common7\IDE\ProjectTemplates 和 <Program Files>\Microsoft Visual Studio 8\Common7\IDE\ItemTemplates

对于用户(任何人)创建的模板,存储在My Documents\Visual Studio 2005\Templates. 如果你想添加一个用户创建的模板到VS的模板列表,你需要做:
1. 拷贝模板(一个模板的Zip文件)到默认的位置(针对不同VS语言版本可能不太一样)
2. 在命令行(VS的命令行)运行devenv /installvstemplates
    注:貌似拷贝到My Documents\Visual Studio 2005\Templates就可以用了

Visual Studio2005也支持内含多个工程的模板,你可以到Craig’s的博客来详细了解:
http://blogs.msdn.com/craigskibo/archive/2004/10/08/240134.aspx

怎么创建用户模板?

一个最简单的方式就是使用‘导出模板向导’。首先,创建一个Class Library工程,然后给工程添加一个图标(这一步其实你可以做任何事情,你对工程做的任何改变都会保存在模板中)。然后点击菜单‘文件->到处模板。向导首先会问你是否要创建一个工程模板还是Item模板。它还会询问你希望基于那个工程来创建这个模板。下一个页面我们可以自定义我们的工程模板,我们可以修改工程模板的名称和描述,还有一个选项问你是否立即导入模板到Visual Studio中(其实也就是自动拷贝模板文件到My Documents\Visual Studio 2005\My Exported Templates to My Documents\Visual Studio 2005\Templates\Project Templates),设置好其它选项,按完成按钮,工程模板就创建好了。

.vstemplate文件中有什么?

注:当我们解压工程模板的zip包后,可以看到整个工程的所有文件,区别于正常的工程,这里多了一个.vstemplate文件,

下边我们来看一下这个文件是做什么用的
这个.vstemplate是特定于你这个工程模板的xml文件,它包含了比如模板的名称、描述等,第二部分包含了一些引用了什么文件的信息。
下边是一个典型的.vstemplate文件(我自己创建的,工程名字是AUTDefinition):

   1: <VSTemplate Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="Project">
   2:   <TemplateData>
   3:     <Name>AUTDefinition</Name>
   4:     <Description>Create the AUT definitioin class library</Description>
   5:     <ProjectType>CSharp</ProjectType>
   6:     <ProjectSubType>
   7:     </ProjectSubType>
   8:     <SortOrder>1000</SortOrder>
   9:     <CreateNewFolder>true</CreateNewFolder>
  10:     <DefaultName>AUTDefinition</DefaultName>
  11:     <ProvideDefaultName>true</ProvideDefaultName>
  12:     <LocationField>Enabled</LocationField>
  13:     <EnableLocationBrowseButton>true</EnableLocationBrowseButton>
  14:     <Icon>__TemplateIcon.ico</Icon>
  15:   </TemplateData>
  16:   <TemplateContent>
  17:     <Project TargetFileName="UICalculator.csproj" File="UICalculator.csproj" ReplaceParameters="true">
  18:       <ProjectItem ReplaceParameters="true" TargetFileName="AUT.cs">AUT.cs</ProjectItem>
  19:       <Folder Name="Properties" TargetFolderName="Properties">
  20:         <ProjectItem ReplaceParameters="true" TargetFileName="AssemblyInfo.cs">AssemblyInfo.cs</ProjectItem>
  21:       </Folder>
  22:     </Project>
  23:   </TemplateContent>
  24: </VSTemplate>

把这篇文章分享到: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • del.icio.us
  • bodytext
  • Google
  • Facebook
  • Furl

你是否知道-你可把代码段拖拽到Toolbox里边

星期五, 04月 11th, 2008

转载翻译自:Did you know… You can drag and drop code onto the Toolbox General tab? - #191

今天的小提示很有意思,特别是如果你在给别人做演示的时候。所有的人都看到你没有写任何代码,但是实际上代码已经准备好了:),让我们看一下如何做吧:

你可以已经注意到Toolbox的General页在你编辑代码的时候默认显示如下:
ToolboxGeneralTab_thumb

其实你可以拖拽代码段到这个地方,在然后需要的时候再拖拽回来,不明白的看下图:
ToolboxGeneralTab2_thumb

把这篇文章分享到: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • del.icio.us
  • bodytext
  • Google
  • Facebook
  • Furl

你是否知道- 你可以在Toolbox中显示所有被隐藏的控件

星期四, 04月 10th, 2008

转载自:Did you know… You can do a "show all" to find your "hiding" toolbox controls - #190

很多问都会奇怪为什么某个控件在Toolbox上找不到了, 特别是当他们刚刚添加了一些控件。(比如:你在Toolbox上点击右键, 选中Choose Items菜单项,然后选择了一些特定的dll和已经注册的控件),但是你有可能找不到你所添加的控件。

出现这种情况的原因就是在Toolbox上边显示的所有控件都被与当前被激活的设计器(designer)相关。设计器都都在VS中相同的位置,你可以用它来设计UI(比如设计一个WinForm的窗口)而不是写代码,在设计器名称的前边会有‘[design]’。因此,如果你当前打开的设计器不支持你新添加的控件,那么它就不会被显示在Toolbox中。

ToolboxShowAll_thumb

通过点击“Show All”, 你可以看到所有的控件。通过这种方式,你可以验证控件是否被正确的添加到Toolbox中,但是控件是否可用,依赖于你打开的设计器是否支持这种控件(不支持的控件显示为灰色)。

toolbox_showall

把这篇文章分享到: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • del.icio.us
  • bodytext
  • Google
  • Facebook
  • Furl