MSBuild Path Mismatch in System Canvas During Cortex-M3 Project Build
The core issue revolves around a mismatch in the MSBuild path configuration when attempting to build a Cortex-M3 "hello world" project using ARM Fast Models and System Canvas. The user encounters a build failure due to System Canvas referencing an incorrect MSBuild path, specifically pointing to the "Professional" version of Visual Studio 2017, while the installed version on the machine is "Enterprise." This discrepancy prevents the build process from completing successfully, as the required MSBuild executable cannot be located.
The error manifests in the build log, which indicates that the build process terminates with an error. The log explicitly shows the path being used by System Canvas: C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\amd64\MSBuild.exe
. However, the user’s installation of Visual Studio 2017 is the Enterprise edition, which places MSBuild in a different directory: C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\amd64\MSBuild.exe
.
This issue is further complicated by the fact that ARM Fast Models and System Canvas are officially validated only with the Professional version of Visual Studio 2017. While the Enterprise version is expected to work, it is not officially supported, which means that any issues arising from its use may not be directly addressed by ARM support.
Incorrect PATH Environment Variable and Visual Studio Configuration
The root cause of the MSBuild path mismatch can be attributed to two primary factors: an incorrectly configured PATH environment variable and potential misconfigurations in the Visual Studio 2017 installation.
PATH Environment Variable Misconfiguration
The PATH environment variable is a critical system setting that dictates where the operating system looks for executable files. In this case, the PATH variable is not correctly set to include the directory containing the MSBuild executable for the Enterprise version of Visual Studio 2017. When System Canvas attempts to locate MSBuild, it defaults to the path specified in the log, which corresponds to the Professional version. This default path is likely hardcoded or derived from a configuration file that does not account for the Enterprise edition.
Visual Studio 2017 Installation Issues
The user’s Visual Studio 2017 installation may lack certain components required for building the Cortex-M3 project. Specifically, the absence of MFC (Microsoft Foundation Classes) and ATL (Active Template Library) support, as well as the Universal CRT SDK (Universal C Runtime Software Development Kit), can prevent the build process from completing successfully. These components are essential for compiling and linking certain types of projects, and their absence can lead to cryptic build errors that are difficult to diagnose without detailed log information.
Additionally, the use of the Enterprise version of Visual Studio 2017 introduces an element of uncertainty, as this version is not officially supported by ARM for use with Fast Models and System Canvas. While the Enterprise version is functionally similar to the Professional version, subtle differences in configuration or component availability could lead to unexpected issues.
Correcting the MSBuild Path and Ensuring Proper Visual Studio Configuration
To resolve the MSBuild path mismatch and ensure a successful build of the Cortex-M3 project, the following steps should be taken:
Verifying and Updating the PATH Environment Variable
The first step is to verify the current configuration of the PATH environment variable and ensure that it includes the correct path to the MSBuild executable for the Enterprise version of Visual Studio 2017. This can be done by opening a command prompt and running the following command:
echo %PATH%
This command will display the current contents of the PATH variable. The output should include the path to the MSBuild executable for the Enterprise version of Visual Studio 2017. If this path is missing, it can be added manually by following these steps:
- Open the System Properties dialog by right-clicking on "This PC" or "Computer" on the desktop or in File Explorer, and selecting "Properties."
- Click on "Advanced system settings" in the left-hand menu.
- In the System Properties window, click on the "Environment Variables" button.
- In the Environment Variables window, locate the "Path" variable in the "System variables" section and select it.
- Click the "Edit" button to modify the Path variable.
- Add the following path to the list of paths:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\amd64
. - Click "OK" to save the changes and close the windows.
After updating the PATH variable, it is recommended to restart any open command prompts or System Canvas instances to ensure that the changes take effect.
Configuring Visual Studio 2017 with Required Components
To ensure that Visual Studio 2017 is correctly configured with all necessary components, the user should verify that MFC, ATL, and the Universal CRT SDK are installed. This can be done through the Visual Studio Installer:
- Open the Visual Studio Installer by searching for "Visual Studio Installer" in the Start menu.
- Locate the installation of Visual Studio 2017 Enterprise and click on the "Modify" button.
- In the "Workloads" tab, ensure that the "Desktop development with C++" workload is selected. This workload includes MFC and ATL support.
- In the "Individual components" tab, search for "Universal CRT SDK" and ensure that it is selected.
- Click the "Modify" button to apply any changes and install the selected components.
Once the installation is complete, restart Visual Studio and attempt to build the Cortex-M3 project again.
Using the Correct Command to Set Up the Build Environment
To ensure that the build environment is correctly configured, the user should use the vcvarsall.bat
script provided by Visual Studio. This script sets up the necessary environment variables for building C++ projects. The correct command to use is:
call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" amd64
This command should be executed in the command prompt before launching System Canvas. It ensures that the correct paths and environment variables are set for the build process.
Launching System Canvas from the Command Line
To obtain more detailed error information, the user should launch System Canvas from the command line using the sgcanvas
command. This approach provides more verbose output, which can be invaluable for diagnosing build issues. The command to launch System Canvas is:
sgcanvas
By running this command after setting up the build environment with vcvarsall.bat
, the user can capture more detailed log information that may reveal the root cause of any build errors.
Reinstalling Visual Studio with Required Components
If the above steps do not resolve the issue, the user may need to reinstall Visual Studio 2017 with the required components. This involves uninstalling the current installation and then reinstalling Visual Studio with the "Desktop development with C++" workload and the Universal CRT SDK component selected. This ensures that all necessary tools and libraries are available for the build process.
Summary of Steps
Step | Action | Command/Path |
---|---|---|
1 | Verify PATH environment variable | echo %PATH% |
2 | Update PATH to include MSBuild for Enterprise | C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\amd64 |
3 | Configure Visual Studio 2017 with required components | Visual Studio Installer |
4 | Set up build environment using vcvarsall.bat |
call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" amd64 |
5 | Launch System Canvas from command line | sgcanvas |
6 | Reinstall Visual Studio with required components if necessary | Visual Studio Installer |
By following these steps, the user should be able to resolve the MSBuild path mismatch and successfully build the Cortex-M3 project using ARM Fast Models and System Canvas.