Tutorial: Build an application - Visual Studio (Windows) (2024)

  • Article

In this article, you'll become more familiar with several options that you can configure when you build applications with Visual Studio. You'll create a custom build configuration, hide certain warning messages, and increase build output information for a sample application.

Install the sample application

The sample code used in this tutorial is found at WPF samples. To clone the repo, use GitHub's green Clone button, and choose Clone in Visual Studio. You can choose the location on the local hard drive to create a copy of the contents of the repo. The repo contains many solutions. If Visual Studio opens one of the solutions, close the solution and then choose Open project or solution, and browse to the location where you cloned the repo, and under that, look for GettingStarted/WalkthroughFirstWPFApp/csharp/ExpenseItIntro.sln to work in C#, or GettingStarted/WalkthroughFirstWPFApp/vb/ExpenseItIntro2.sln to work in Visual Basic.

Create a custom build configuration

When you create a solution, Debug and Release build configurations and their default platform targets are defined for the solution automatically. You can then customize these configurations or create your own. Build configurations specify the build type. Build platforms specify the operating system that an application targets for that configuration. For more information, see Understand build configurations, Configure projects to target platforms, and How to: Set debug and release configurations.

You can change or create configurations and platform settings by using the Configuration Manager dialog box. In this procedure, you'll create a build configuration for testing.

Create a build configuration

  1. Open the Configuration Manager dialog box.

    Tutorial: Build an application - Visual Studio (Windows) (1)

  2. In the Active solution configuration list, choose <New...>.

    Tutorial: Build an application - Visual Studio (Windows) (2)

  3. In the New Solution Configuration dialog box, name the new configuration Test, copy settings from the existing Debug configuration, and then choose the OK button.

    Tutorial: Build an application - Visual Studio (Windows) (3)

  4. In the Active solution platform list, choose <New...>.

  5. In the New Solution Platform dialog box, choose x64, and don't copy settings from the x86 platform.

    Tutorial: Build an application - Visual Studio (Windows) (4)

  6. Choose the OK button.

    The active solution configuration has been changed to Test with the active solution platform set to x64.

    Tutorial: Build an application - Visual Studio (Windows) (5)

  7. Choose Close.

You can quickly verify or change the active solution configuration by using the Solution Configurations list on the Standard toolbar.

Tutorial: Build an application - Visual Studio (Windows) (6)

  1. Open the Configuration Manager dialog box.

    Tutorial: Build an application - Visual Studio (Windows) (7)

  2. In the Active solution configuration list, choose <New...>.

    Tutorial: Build an application - Visual Studio (Windows) (8)

  3. In the New Solution Configuration dialog box, name the new configuration Test, copy settings from the existing Debug configuration, and then choose the OK button.

    Tutorial: Build an application - Visual Studio (Windows) (9)

  4. In the Platform column, expand the dropdown list, and choose <New...> to create a new project platform.

    Tutorial: Build an application - Visual Studio (Windows) (10)

  5. In the New Project Platform dialog box, choose x64, and don't copy settings from the x86 platform.

    Tutorial: Build an application - Visual Studio (Windows) (11)

    If the x64 solution platform already exists, uncheck the Create active solution platform box.

  6. Choose the OK button.

    The active solution configuration has been changed to Test with the active solution platform set to x64.

    Tutorial: Build an application - Visual Studio (Windows) (12)

  7. Choose Close.

You can quickly verify or change the active solution configuration by using the Solution Configurations list on the Standard toolbar.

Tutorial: Build an application - Visual Studio (Windows) (13)

Note

If you don't see the active solution configuration or the active platform shown in the toolbar, choose the small arrow-like icon on the far right of the toolbar, and then choose Add or remove buttons. Be sure that Solution Configurations and Solution Platforms are enabled.

Build the application

Next, you'll build the solution with the custom build configuration.

Build the solution

  • On the menu bar, choose Build > Build Solution, or press Ctrl+Shift+B.

    The Output window displays the results of the build. The build succeeded.

Hide compiler warnings

Next we'll introduce some code that causes a warning to be generated by the compiler.

  1. In the C# project, open the ExpenseReportPage.xaml.cs file. In the ExpenseReportPage method, add the following code: int i;.

    OR

    In the Visual Basic project, open the ExpenseReportPage.xaml.vb file. In the custom constructor Public Sub New..., add the following code: Dim i.

  2. Build the solution.

The Output window displays the results of the build. The build succeeded, but warnings were generated:

Tutorial: Build an application - Visual Studio (Windows) (14)

Tutorial: Build an application - Visual Studio (Windows) (15)

Tutorial: Build an application - Visual Studio (Windows) (16)

Tutorial: Build an application - Visual Studio (Windows) (17)

You can temporarily hide certain warning messages during a build rather than have them clutter up the build output.

Hide a specific C# warning

  1. In Solution Explorer, choose the top-level project node.

  2. On the menu bar, choose View > Property Pages.

    The Project Designer opens.

  3. Choose the Build tab or section and then, in the Suppress warnings box, specify the warning number 0168. If other warnings are already listed, use a semicolon as a separator.

    Tutorial: Build an application - Visual Studio (Windows) (18)

    Tutorial: Build an application - Visual Studio (Windows) (19)

    For more information, see Build Page, Project Designer (C#).

  4. Build the solution using Build > Rebuild Solution.

    The Output window displays only summary information for the build (no warnings).

    Tutorial: Build an application - Visual Studio (Windows) (20)

    Tutorial: Build an application - Visual Studio (Windows) (21)

Suppress all Visual Basic build warnings

  1. In Solution Explorer, choose the top-level project node.

  2. On the menu bar, choose View > Property Pages.

    The Project Designer opens.

  3. On the Compile page, select the Disable all warnings check box.

    Tutorial: Build an application - Visual Studio (Windows) (22)

    Tutorial: Build an application - Visual Studio (Windows) (23)

    For more information, see Configure warnings in Visual Basic.

  4. Build the solution. If it doesn't rebuild, build the solution using Build > Rebuild Solution.

    The Output window displays only summary information for the build (no warnings).

    Tutorial: Build an application - Visual Studio (Windows) (24)

    Tutorial: Build an application - Visual Studio (Windows) (25)

    For more information, see How to: Suppress compiler warnings.

Display additional build details in the Output window

You can change how much information about the build process appears in the Output window. Build verbosity is usually set to Minimal, which means that the Output window displays only a summary of the build process along with any high priority warnings or errors. You can display more information about the build by using the Options dialog box, Projects and Solutions, Build and Run.

Important

If you display more information, the build will take longer to complete.

Change the amount of information in the Output window

  1. Open the Options dialog box.

    Tutorial: Build an application - Visual Studio (Windows) (26)

    Tutorial: Build an application - Visual Studio (Windows) (27)

  2. Choose the Projects and Solutions category, and then choose the Build and Run page.

  3. In the MSBuild project build output verbosity list, choose Normal, and then choose the OK button.

  4. On the menu bar, choose Build > Clean Solution.

  5. Build the solution, and then review the information in the Output window.

    The build information includes the time that the build started (located at the beginning) and the order in which files were processed. This information also includes the actual compiler syntax that Visual Studio runs during the build.

    For example, in the C# build, the /nowarn option lists the warning code, 0168, that you specified earlier in this topic, along with three other warnings.

    In the Visual Basic build, /nowarn doesn't include specific warnings to exclude, so no warnings appear.

    Tip

    You can search the contents of the Output window if you display the Find dialog box by choosing the Ctrl+F keys.

For more information, see How to: View, save, and configure build log files.

Create a Release Build

You can build a version of the sample application that's optimized for shipping it. For the release build, you'll specify that the executable is copied to a network share before the build is kicked off.

For more information, see How to: Change the build output directory and Build and clean projects and solutions in Visual Studio.

Specify a release build for Visual Basic

  1. To open the Project Designer, select the project node in Solution Explorer by right-clicking and choose Properties (or press Alt+Enter), or on the View menu, choose Property Pages:

    Tutorial: Build an application - Visual Studio (Windows) (28)

    Tutorial: Build an application - Visual Studio (Windows) (29)

  2. Choose the Compile page.

  3. In the Configuration list, choose Release.

  4. In the Platform list, choose x86.

  5. In the Build output path box, specify a network path.

    For example, you can specify \\myserver\builds.

    Important

    A message box might appear, warning you that the network share that you've specified might not be a trusted location. If you trust the location that you've specified, choose the OK button in the message box.

  6. Build the application.

    Tutorial: Build an application - Visual Studio (Windows) (30)

    Tutorial: Build an application - Visual Studio (Windows) (31)

Specify a release build for C#

  1. Open the Project Designer.

    Tutorial: Build an application - Visual Studio (Windows) (32)

    Tutorial: Build an application - Visual Studio (Windows) (33)

  2. Choose the Build page.

  3. In the Configuration list, choose Release.

  4. In the Platform list, choose x86.

  5. In the Output path box, specify a network path.

    For example, you could specify \\myserver\builds.

    Important

    A message box might appear, warning you that the network share that you've specified might not be a trusted location. If you trust the location that you've specified, choose the OK button in the message box.

  6. On the Standard toolbar, set the Solution Configurations to Release and the Solution Platforms to x86.

  7. Build the application.

    Tutorial: Build an application - Visual Studio (Windows) (34)

    Tutorial: Build an application - Visual Studio (Windows) (35)

    The executable file is copied to the network path that you specified. Its path would be \\myserver\builds\\FileName.exe.

Congratulations! You've successfully completed this tutorial.

See also

  • Walkthrough: Build a project (C++)
  • ASP.NET web application project precompilation overview
  • Walkthrough: Use MSBuild
Tutorial: Build an application - Visual Studio (Windows) (2024)

FAQs

What is the difference between build and rebuild in Visual Studio? ›

Build means compile and link only the source files that have changed since the last build, while Rebuild means compile and link all source files regardless of whether they changed or not. Build is the normal thing to do and is faster.

How to create an .exe file in Visual Studio? ›

How to create a Setup.exe file in Visual Studio
  1. Add Microsoft Visual Studio Installer Projects extension. ...
  2. Add the setup project to your application. ...
  3. Add the project output. ...
  4. Edit the product details. ...
  5. Create shortcuts for the application. ...
  6. Customize a shortcut with an icon. ...
  7. Add launch conditions. ...
  8. Install Prerequisites.
Jun 29, 2023

How do I Create a build in Visual Studio? ›

To build or rebuild a single project
  1. In Solution Explorer, choose or open the project.
  2. On the menu bar, choose Build, and then choose either Build ProjectName or Rebuild ProjectName. Choose Build ProjectName to build only those project components that have changed since the most recent build.
Oct 17, 2023

How do I Create a new program in Visual Studio? ›

Create empty solutions
  1. On the menu bar, select File > New > Project.
  2. On the Create a new project page, type solution into the search box.
  3. Select the Blank Solution template, and then select Next.
  4. Enter Name and Location values for your solution, and then select Create.
Aug 8, 2023

How do I make an application start in Windows? ›

Go to Start > Settings > Apps > Startup. For any app in the list, select the toggle to set it to On. If you want to change the advanced settings for that app, select the arrow and make changes as desired.

How do you build an application? ›

In simple terms, you need to:
  1. Define your app concept & target audience.
  2. Determine the monetization model.
  3. Decide on the features.
  4. Create user journeys & wireframes.
  5. Design the user interface (UI)
  6. Create the app in a test environment.
  7. Conduct quality assurance (QA)
  8. Upload it to the app store.
Jun 18, 2024

What happens when you build in Visual Studio? ›

Visual Studio determines the build order and calls into MSBuild separately (as needed), all completely under Visual Studio's control. Another difference arises when MSBuild is invoked with a solution file, MSBuild parses the solution file, creates a standard XML input file, evaluates it, and executes it as a project.

What is Visual Studio build tool? ›

Overview. MSBuild is a build tool that helps automate the process of creating a software product, including compiling the source code, packaging, testing, deployment and creating documentations. With MSBuild, it is possible to build Visual Studio projects and solutions without the Visual Studio IDE installed.

What build system does Visual Studio use? ›

MSBuild is the native build system for Visual Studio and is generally the best build system to use for Windows-specific programs.

Why is the .exe file not created in Visual Studio? ›

You have compiler errors. Since your code doesn't compile then no exe can be produced. You have to fix the compiler errors. The actual error is that it cannot find the crtdbg.

How to build release in Visual Studio? ›

In Solution Explorer, right-click the project and choose Properties. In the side pane, choose Build (or Compile in Visual Basic). In the Configuration list at the top, choose Debug or Release.

How to make an executable file in Windows? ›

  1. Part 1 of 2:Creating an EXE File. Open Start . ...
  2. Type notepad into Start. This will search your computer for the Notepad app.
  3. Click Notepad. ...
  4. Enter your EXE's program code. ...
  5. Click the "Save as type" drop-down box. ...
  6. Enter a name for your EXE file. ...
  7. Click Save.
Feb 22, 2021

Can I build an app in VS Code? ›

You can create a new JavaFX application with just a few steps in VS Code: Step 1: Install the Extension Pack for Java. Step 2: In Visual Studio Code, open the Command Palette (Ctrl+Shift+P) and then select the command Java: Create Java Project.

What type of application program can be built using Visual Studio? ›

Visual Studio is an integrated development environment (IDE) developed by Microsoft. It is used to develop computer programs including websites, web apps, web services and mobile apps.

How to compile a program in Visual Studio? ›

Compiling Visual Studio Projects
  1. Click Terminal > Run Build Task. This shows the Task Picker with the supplied build tasks - one for building the project file, and one for building the solution. ...
  2. Check the Problems panel for any issues.

References

Top Articles
Latest Posts
Article information

Author: Mrs. Angelic Larkin

Last Updated:

Views: 6119

Rating: 4.7 / 5 (47 voted)

Reviews: 94% of readers found this page helpful

Author information

Name: Mrs. Angelic Larkin

Birthday: 1992-06-28

Address: Apt. 413 8275 Mueller Overpass, South Magnolia, IA 99527-6023

Phone: +6824704719725

Job: District Real-Estate Facilitator

Hobby: Letterboxing, Vacation, Poi, Homebrewing, Mountain biking, Slacklining, Cabaret

Introduction: My name is Mrs. Angelic Larkin, I am a cute, charming, funny, determined, inexpensive, joyous, cheerful person who loves writing and wants to share my knowledge and understanding with you.