MSBuild: By Example—Editing MSBuild Files with Intellisense

Microsoft .NET Framework, ASP.NET, Visual C# (CSharp, C Sharp, C-Sharp) Developer Training, Visual Studio


Jump to: navigation, search
CSharp-Online.NET:Articles
Visual Studio Articles

MSBuild: By Example

© 2006 Hashimi & Hashimi

Editing MSBuild Files with IntelliSense

You can edit your MSBuild files in any way you’d like. You can use any text/XML editor that you desire. If you use a simple tool, such as Notepad, this will work, but it will not provide you with any assistance as your create your project files. Some XML editors use the XML Schema Document (XSD) to give you some assistance. One such tool is Visual Studio! If you open your project file inside Visual Studio, then IntelliSense will be enabled, and you will be able to create your MSBuild files much more quickly.

Visual Studio’s IntelliSense is particularly useful when you know what you want to do but don’t remember all the details. For instance, if you are creating a target to copy all your source files that need to call the Copy task, you may not remember what all of its attributes are. If you open the file in Visual Studio, then as you create the new target, you will be given the list of options available to you. For example, as you are creating the call to the Copy task, you will be provided with a list like the one shown in Figure 3-7 that tells you the names of the attributes.



Figure 3-7. Visual Studio IntelliSense for MSBuild files


In Figure 3-7 you can see how you will spend less time if you create your MSBuild files using Visual Studio. This will also decrease the amount of errors you create as your write your targets. If you are developing your project using Visual Studio and you want to edit the project file concurrently, then you have two options for using Visual Studio as your editor:

* Open a new instance of Visual Studio, and load your project file there.

* Unload your project, edit your project file, and then reload your project.

You can employ the option of opening your project file in a new instance of Visual Studio. If you’d like to have only a single instance of Visual Studio, then you can follow these steps:

1. Unload the project. You can do this in the Solution Explorer by right-clicking the project and then selecting Unload Project. If you have a file from that project open, you can select Project -> Unload Project.

2. Open the project file for editing. To do this, select File -> Open -> File.


Note You cannot drag and drop the project file into Visual Studio.


3. Select your project file, and click Open.

4. Edit your project file, and then save the changes.

5. Close the project file.

6. Reload the project.


Previous_Page_.gif Next_Page_.gif

Personal tools