I am investigated rules_msbuild. I am try building an Hello World console application, but I am unsuccessful.
The builder.exe utility tool running the building action is failing with the following error:
System.TypeLoadException: Could not load type 'Microsoft.Build.Utilities.ChangeWaves' from assembly 'Microsoft.Build.Framework, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
at Microsoft.Build.Evaluation.Evaluator`4.AddBuiltInProperties()
at Microsoft.Build.Evaluation.Evaluator`4.Evaluate() in /Users/samh/dev/samhowes.msbuild/_work/msbuild/src/Build/Evaluation/Evaluator.cs:line 597
Click to show the full error message
```
ERROR: C:/code/bazel_test_dotnet/MyApp/BUILD:4:15: NuGetRestore MyApp/restore/_/project.assets.json failed: (Exit -532462766): dotnet.exe failed: error executing command
cd /d C:/users/johndoo/_bazel_johndoo/ahfrrly4/execroot/bazel_test_dotnet
SET APPDATA=external/dotnet_sdk
SET BINDIR=bazel-out/x64_windows-fastbuild/bin
SET DOTNET_CLI_HOME=external/dotnet_sdk
SET DOTNET_CLI_TELEMETRY_OPTOUT=1
SET DOTNET_MULTILEVEL_LOOKUP=0
SET DOTNET_NOLOGO=1
SET DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
SET LOCALAPPDATA=external/dotnet_sdk
SET PROGRAMFILES=external/dotnet_sdk
SET ProgramFiles(x86)=external/dotnet_sdk
SET RULES_MSBUILD_VERSION=0.0.17
SET USERPROFILE=external/dotnet_sdk
external\dotnet_sdk\dotnet.exe bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/dotnet_sdk/publish/builder.dll restore --sdk_root external/dotnet_sdk/sdk/6.0.401 --project_file MyApp/MyApp.csproj --bazel_bin_dir bazel-out/x64_windows-fastbuild/bin --tfm net6.0 --bazel_output_base C:/users/johndoo/_bazel_johndoo/ahfrrly4 --workspace bazel_test_dotnet --package MyApp --label_name MyApp_restore --nuget_config external/nuget/NuGet.Build.Config --directory_bazel_props external/dotnet_sdk/Directory.Bazel.props --configuration fastbuild --output_type library --directory [] --assembly_name MyApp --version --package_version
# Configuration: d808f536a2e7e477aedb41a9a5182ac1f525db92a3fc27b3f18e4ea2d5cdcd9b
# Execution platform: @local_config_platform//:host
Unhandled exception. System.Exception: An exception occurred while loading project C:\users\johndoo\_bazel_johndoo\ahfrrly4\execroot\bazel_test_dotnet\MyApp\MyApp.csproj.
---> System.TypeLoadException: Could not load type 'Microsoft.Build.Utilities.ChangeWaves' from assembly 'Microsoft.Build.Framework, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
at Microsoft.Build.Evaluation.Evaluator`4.AddBuiltInProperties()
at Microsoft.Build.Evaluation.Evaluator`4.Evaluate() in /Users/samh/dev/samhowes.msbuild/_work/msbuild/src/Build/Evaluation/Evaluator.cs:line 597
at Microsoft.Build.Execution.ProjectInstance.Initialize(ProjectRootElement xml, IDictionary`2 globalProperties, String explicitToolsVersion, String explicitSubToolsetVersion, Int32 visualStudioVersionFromSolution, BuildParameters buildParameters, ILoggingService loggingService, BuildEventContext buildEventContext, ISdkResolverService sdkResolverService, Int32 submissionId, Nullable`1 projectLoadSettings, EvaluationContext evaluationContext) in /Users/samh/dev/samhowes.msbuild/_work/msbuild/src/Build/Instance/ProjectInstance.cs:line 2673
at Microsoft.Build.Execution.ProjectInstance..ctor(String projectFile, IDictionary`2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectCollection projectCollection, Nullable`1
projectLoadSettings, EvaluationContext evaluationContext) in /Users/samh/dev/samhowes.msbuild/_work/msbuild/src/Build/Instance/ProjectInstance.cs:line 277
at Microsoft.Build.Execution.ProjectInstance..ctor(String projectFile, IDictionary`2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectCollection projectCollection) in /Users/samh/dev/samhowes.msbuild/_work/msbuild/src/Build/Instance/ProjectInstance.cs:line 243
at Microsoft.Build.Execution.ProjectInstance..ctor(String projectFile, IDictionary`2 globalProperties, String toolsVersion, ProjectCollection projectCollection) in /Users/samh/dev/samhowes.msbuild/_work/msbuild/src/Build/Instance/ProjectInstance.cs:line 225
at RulesMSBuild.Tools.Builder.ProjectLoader.CreateProjectInstanceImpl(String projectPath, Dictionary`2 globalProperties, ProjectCollection projectCollection) in C:\users\johndoo\_bazel_johndoo\ahfrrly4\execroot\bazel_test_dotnet\external\rules_msbuild\dotnet\tools\builder\ProjectLoader.cs:line 79
at RulesMSBuild.Tools.Builder.ProjectLoader.CreateProjectInstance(String projectPath, Dictionary`2 globalProperties, ProjectCollection projectCollection) in C:\users\johndoo\_bazel_johndoo\ahfrrly4\execroot\bazel_test_dotnet\external\rules_msbuild\dotnet\tools\builder\ProjectLoader.cs:line 55
--- End of inner exception stack trace ---
at RulesMSBuild.Tools.Builder.ProjectLoader.CreateProjectInstance(String projectPath, Dictionary`2 globalProperties, ProjectCollection projectCollection) in C:\users\johndoo\_bazel_johndoo\ahfrrly4\execroot\bazel_test_dotnet\external\rules_msbuild\dotnet\tools\builder\ProjectLoader.cs:line 60
at Microsoft.Build.Graph.GraphBuilder.ParseProject(ConfigurationMetadata configurationMetadata) in /Users/samh/dev/samhowes.msbuild/_work/msbuild/src/Build/Graph/GraphBuilder.cs:line 499
at Microsoft.Build.Graph.GraphBuilder.<>c__DisplayClass35_0.b__0() in /Users/samh/dev/samhowes.msbuild/_work/msbuild/src/Build/Graph/GraphBuilder.cs:line 539
at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
at System.Lazy`1.CreateValue()
at System.Lazy`1.get_Value()
at Microsoft.Build.Graph.ParallelWorkSet`2.ExecuteWorkItem() in /Users/samh/dev/samhowes.msbuild/_work/msbuild/src/Build/Graph/ParallelWorkSet.cs:line 180
at Microsoft.Build.Graph.ParallelWorkSet`2.WaitForAllWorkAndComplete() in /Users/samh/dev/samhowes.msbuild/_work/msbuild/src/Build/Graph/ParallelWorkSet.cs:line 132
at Microsoft.Build.Graph.GraphBuilder.FindGraphNodes() in /Users/samh/dev/samhowes.msbuild/_work/msbuild/src/Build/Graph/GraphBuilder.cs:line 532
at Microsoft.Build.Graph.GraphBuilder.BuildGraph() in /Users/samh/dev/samhowes.msbuild/_work/msbuild/src/Build/Graph/GraphBuilder.cs:line 82
at Microsoft.Build.Graph.ProjectGraph..ctor(IEnumerable`1 entryPoints, ProjectCollection projectCollection, ProjectInstanceFactoryFunc projectInstanceFactory, Int32 degreeOfParallelism, CancellationToken cancellationToken) in /Users/samh/dev/samhowes.msbuild/_work/msbuild/src/Build/Graph/ProjectGraph.cs:line 430
at RulesMSBuild.Tools.Builder.ProjectLoader.Load(ProjectCollection projectCollection) in C:\users\johndoo\_bazel_johndoo\ahfrrly4\execroot\bazel_test_dotnet\external\rules_msbuild\dotnet\tools\builder\ProjectLoader.cs:line 41
at RulesMSBuild.Tools.Builder.Builder.BeginBuild() in C:\users\johndoo\_bazel_johndoo\ahfrrly4\execroot\bazel_test_dotnet\external\rules_msbuild\dotnet\tools\builder\Builder.cs:line 159
at RulesMSBuild.Tools.Builder.Builder.Build() in C:\users\johndoo\_bazel_johndoo\ahfrrly4\execroot\bazel_test_dotnet\external\rules_msbuild\dotnet\tools\builder\Builder.cs:line 86
at RulesMSBuild.Tools.Builder.Program.Build(BuildCommand command) in C:\users\johndoo\_bazel_johndoo\ahfrrly4\execroot\bazel_test_dotnet\external\rules_msbuild\dotnet\tools\builder\Program.cs:line 196
at RulesMSBuild.Tools.Builder.Program.Main(String[] args) in C:\users\johndoo\_bazel_johndoo\ahfrrly4\execroot\bazel_test_dotnet\external\rules_msbuild\dotnet\tools\builder\Program.cs:line 61
Target //MyApp:MyApp failed to build
ERROR: C:/code/bazel_test_dotnet/MyApp/BUILD:4:15 MSBuild MyApp/net6.0 failed: (Exit -532462766): dotnet.exe failed: error executing command
cd /d C:/users/johndoo/_bazel_johndoo/ahfrrly4/execroot/bazel_test_dotnet
SET APPDATA=external/dotnet_sdk
SET BINDIR=bazel-out/x64_windows-fastbuild/bin
SET DOTNET_CLI_HOME=external/dotnet_sdk
SET DOTNET_CLI_TELEMETRY_OPTOUT=1
SET DOTNET_MULTILEVEL_LOOKUP=0
SET DOTNET_NOLOGO=1
SET DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
SET LOCALAPPDATA=external/dotnet_sdk
SET PROGRAMFILES=external/dotnet_sdk
SET ProgramFiles(x86)=external/dotnet_sdk
SET RULES_MSBUILD_VERSION=0.0.17
SET USERPROFILE=external/dotnet_sdk
external\dotnet_sdk\dotnet.exe bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/dotnet_sdk/publish/builder.dll restore --sdk_root external/dotnet_sdk/sdk/6.0.401 --project_file MyApp/MyApp.csproj --bazel_bin_dir bazel-out/x64_windows-fastbuild/bin --tfm net6.0 --bazel_output_base C:/users/johndoo/_bazel_johndoo/ahfrrly4 --workspace bazel_test_dotnet --package MyApp --label_name MyApp_restore --nuget_config external/nuget/NuGet.Build.Config --directory_bazel_props external/dotnet_sdk/Directory.Bazel.props --configuration fastbuild --output_type library --directory [] --assembly_name MyApp --version --package_version
# Configuration: d808f536a2e7e477aedb41a9a5182ac1f525db92a3fc27b3f18e4ea2d5cdcd9b
# Execution platform: @local_config_platform//:host
```
Problem
I am investigated rules_msbuild. I am try building an Hello World console application, but I am unsuccessful.
The builder.exe utility tool running the building action is failing with the following error:
Click to show the full error message
``` ERROR: C:/code/bazel_test_dotnet/MyApp/BUILD:4:15: NuGetRestore MyApp/restore/_/project.assets.json failed: (Exit -532462766): dotnet.exe failed: error executing command cd /d C:/users/johndoo/_bazel_johndoo/ahfrrly4/execroot/bazel_test_dotnet SET APPDATA=external/dotnet_sdk SET BINDIR=bazel-out/x64_windows-fastbuild/bin SET DOTNET_CLI_HOME=external/dotnet_sdk SET DOTNET_CLI_TELEMETRY_OPTOUT=1 SET DOTNET_MULTILEVEL_LOOKUP=0 SET DOTNET_NOLOGO=1 SET DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 SET LOCALAPPDATA=external/dotnet_sdk SET PROGRAMFILES=external/dotnet_sdk SET ProgramFiles(x86)=external/dotnet_sdk SET RULES_MSBUILD_VERSION=0.0.17 SET USERPROFILE=external/dotnet_sdk external\dotnet_sdk\dotnet.exe bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/dotnet_sdk/publish/builder.dll restore --sdk_root external/dotnet_sdk/sdk/6.0.401 --project_file MyApp/MyApp.csproj --bazel_bin_dir bazel-out/x64_windows-fastbuild/bin --tfm net6.0 --bazel_output_base C:/users/johndoo/_bazel_johndoo/ahfrrly4 --workspace bazel_test_dotnet --package MyApp --label_name MyApp_restore --nuget_config external/nuget/NuGet.Build.Config --directory_bazel_props external/dotnet_sdk/Directory.Bazel.props --configuration fastbuild --output_type library --directory [] --assembly_name MyApp --version --package_version # Configuration: d808f536a2e7e477aedb41a9a5182ac1f525db92a3fc27b3f18e4ea2d5cdcd9b # Execution platform: @local_config_platform//:host Unhandled exception. System.Exception: An exception occurred while loading project C:\users\johndoo\_bazel_johndoo\ahfrrly4\execroot\bazel_test_dotnet\MyApp\MyApp.csproj. ---> System.TypeLoadException: Could not load type 'Microsoft.Build.Utilities.ChangeWaves' from assembly 'Microsoft.Build.Framework, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. at Microsoft.Build.Evaluation.Evaluator`4.AddBuiltInProperties() at Microsoft.Build.Evaluation.Evaluator`4.Evaluate() in /Users/samh/dev/samhowes.msbuild/_work/msbuild/src/Build/Evaluation/Evaluator.cs:line 597 at Microsoft.Build.Execution.ProjectInstance.Initialize(ProjectRootElement xml, IDictionary`2 globalProperties, String explicitToolsVersion, String explicitSubToolsetVersion, Int32 visualStudioVersionFromSolution, BuildParameters buildParameters, ILoggingService loggingService, BuildEventContext buildEventContext, ISdkResolverService sdkResolverService, Int32 submissionId, Nullable`1 projectLoadSettings, EvaluationContext evaluationContext) in /Users/samh/dev/samhowes.msbuild/_work/msbuild/src/Build/Instance/ProjectInstance.cs:line 2673 at Microsoft.Build.Execution.ProjectInstance..ctor(String projectFile, IDictionary`2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectCollection projectCollection, Nullable`1 projectLoadSettings, EvaluationContext evaluationContext) in /Users/samh/dev/samhowes.msbuild/_work/msbuild/src/Build/Instance/ProjectInstance.cs:line 277 at Microsoft.Build.Execution.ProjectInstance..ctor(String projectFile, IDictionary`2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectCollection projectCollection) in /Users/samh/dev/samhowes.msbuild/_work/msbuild/src/Build/Instance/ProjectInstance.cs:line 243 at Microsoft.Build.Execution.ProjectInstance..ctor(String projectFile, IDictionary`2 globalProperties, String toolsVersion, ProjectCollection projectCollection) in /Users/samh/dev/samhowes.msbuild/_work/msbuild/src/Build/Instance/ProjectInstance.cs:line 225 at RulesMSBuild.Tools.Builder.ProjectLoader.CreateProjectInstanceImpl(String projectPath, Dictionary`2 globalProperties, ProjectCollection projectCollection) in C:\users\johndoo\_bazel_johndoo\ahfrrly4\execroot\bazel_test_dotnet\external\rules_msbuild\dotnet\tools\builder\ProjectLoader.cs:line 79 at RulesMSBuild.Tools.Builder.ProjectLoader.CreateProjectInstance(String projectPath, Dictionary`2 globalProperties, ProjectCollection projectCollection) in C:\users\johndoo\_bazel_johndoo\ahfrrly4\execroot\bazel_test_dotnet\external\rules_msbuild\dotnet\tools\builder\ProjectLoader.cs:line 55 --- End of inner exception stack trace --- at RulesMSBuild.Tools.Builder.ProjectLoader.CreateProjectInstance(String projectPath, Dictionary`2 globalProperties, ProjectCollection projectCollection) in C:\users\johndoo\_bazel_johndoo\ahfrrly4\execroot\bazel_test_dotnet\external\rules_msbuild\dotnet\tools\builder\ProjectLoader.cs:line 60 at Microsoft.Build.Graph.GraphBuilder.ParseProject(ConfigurationMetadata configurationMetadata) in /Users/samh/dev/samhowes.msbuild/_work/msbuild/src/Build/Graph/GraphBuilder.cs:line 499 at Microsoft.Build.Graph.GraphBuilder.<>c__DisplayClass35_0.b__0() in /Users/samh/dev/samhowes.msbuild/_work/msbuild/src/Build/Graph/GraphBuilder.cs:line 539
at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
at System.Lazy`1.CreateValue()
at System.Lazy`1.get_Value()
at Microsoft.Build.Graph.ParallelWorkSet`2.ExecuteWorkItem() in /Users/samh/dev/samhowes.msbuild/_work/msbuild/src/Build/Graph/ParallelWorkSet.cs:line 180
at Microsoft.Build.Graph.ParallelWorkSet`2.WaitForAllWorkAndComplete() in /Users/samh/dev/samhowes.msbuild/_work/msbuild/src/Build/Graph/ParallelWorkSet.cs:line 132
at Microsoft.Build.Graph.GraphBuilder.FindGraphNodes() in /Users/samh/dev/samhowes.msbuild/_work/msbuild/src/Build/Graph/GraphBuilder.cs:line 532
at Microsoft.Build.Graph.GraphBuilder.BuildGraph() in /Users/samh/dev/samhowes.msbuild/_work/msbuild/src/Build/Graph/GraphBuilder.cs:line 82
at Microsoft.Build.Graph.ProjectGraph..ctor(IEnumerable`1 entryPoints, ProjectCollection projectCollection, ProjectInstanceFactoryFunc projectInstanceFactory, Int32 degreeOfParallelism, CancellationToken cancellationToken) in /Users/samh/dev/samhowes.msbuild/_work/msbuild/src/Build/Graph/ProjectGraph.cs:line 430
at RulesMSBuild.Tools.Builder.ProjectLoader.Load(ProjectCollection projectCollection) in C:\users\johndoo\_bazel_johndoo\ahfrrly4\execroot\bazel_test_dotnet\external\rules_msbuild\dotnet\tools\builder\ProjectLoader.cs:line 41
at RulesMSBuild.Tools.Builder.Builder.BeginBuild() in C:\users\johndoo\_bazel_johndoo\ahfrrly4\execroot\bazel_test_dotnet\external\rules_msbuild\dotnet\tools\builder\Builder.cs:line 159
at RulesMSBuild.Tools.Builder.Builder.Build() in C:\users\johndoo\_bazel_johndoo\ahfrrly4\execroot\bazel_test_dotnet\external\rules_msbuild\dotnet\tools\builder\Builder.cs:line 86
at RulesMSBuild.Tools.Builder.Program.Build(BuildCommand command) in C:\users\johndoo\_bazel_johndoo\ahfrrly4\execroot\bazel_test_dotnet\external\rules_msbuild\dotnet\tools\builder\Program.cs:line 196
at RulesMSBuild.Tools.Builder.Program.Main(String[] args) in C:\users\johndoo\_bazel_johndoo\ahfrrly4\execroot\bazel_test_dotnet\external\rules_msbuild\dotnet\tools\builder\Program.cs:line 61
Target //MyApp:MyApp failed to build
ERROR: C:/code/bazel_test_dotnet/MyApp/BUILD:4:15 MSBuild MyApp/net6.0 failed: (Exit -532462766): dotnet.exe failed: error executing command
cd /d C:/users/johndoo/_bazel_johndoo/ahfrrly4/execroot/bazel_test_dotnet
SET APPDATA=external/dotnet_sdk
SET BINDIR=bazel-out/x64_windows-fastbuild/bin
SET DOTNET_CLI_HOME=external/dotnet_sdk
SET DOTNET_CLI_TELEMETRY_OPTOUT=1
SET DOTNET_MULTILEVEL_LOOKUP=0
SET DOTNET_NOLOGO=1
SET DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
SET LOCALAPPDATA=external/dotnet_sdk
SET PROGRAMFILES=external/dotnet_sdk
SET ProgramFiles(x86)=external/dotnet_sdk
SET RULES_MSBUILD_VERSION=0.0.17
SET USERPROFILE=external/dotnet_sdk
external\dotnet_sdk\dotnet.exe bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/dotnet_sdk/publish/builder.dll restore --sdk_root external/dotnet_sdk/sdk/6.0.401 --project_file MyApp/MyApp.csproj --bazel_bin_dir bazel-out/x64_windows-fastbuild/bin --tfm net6.0 --bazel_output_base C:/users/johndoo/_bazel_johndoo/ahfrrly4 --workspace bazel_test_dotnet --package MyApp --label_name MyApp_restore --nuget_config external/nuget/NuGet.Build.Config --directory_bazel_props external/dotnet_sdk/Directory.Bazel.props --configuration fastbuild --output_type library --directory [] --assembly_name MyApp --version --package_version
# Configuration: d808f536a2e7e477aedb41a9a5182ac1f525db92a3fc27b3f18e4ea2d5cdcd9b
# Execution platform: @local_config_platform//:host
```
I do not know how to investigate this problem.
Details
Here is the archite of my test project: bazel_test_dotnet.zip
I have the last .Net 6.0.401 installed on my computer at the standard location.
Click to show //MyApp/BUILD
``` # //Console/BUILD load("@rules_msbuild//dotnet:defs.bzl", "msbuild_binary") msbuild_binary( name = "MyApp", # adds the property AssemblyName="hello" srcs = ["Program.cs"], # omitting srcs automatically globs the directory for source files project_file = "MyApp.csproj", # project_file is specified when AssemblyName is different target_framework = "net6.0", visibility = ["//visibility:public"], ) ```
Click to show //BUILD
``` # bzl:generated start load("@rules_msbuild//dotnet:defs.bzl", "msbuild_directory") load("@rules_msbuild//tools:gazelle.bzl", "gazelle") msbuild_directory( name = "msbuild_defaults", srcs = [ "Bazel.props", "Bazel.targets", "Directory.Build.props", "Directory.Build.targets", "Directory.Solution.props", "Directory.Solution.targets", ], visibility = ["//:__subpackages__"], ) gazelle( name = "gazelle", args = [ "--deps_macro=deps/nuget.bzl%nuget_deps", "--srcs_mode=explicit", ], ) # bzl:generated end ```
Click to //WORKSPACE
``` workspace(name = "bazel_test_dotnet") # bzl:generated start load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") http_archive( name = "rules_msbuild", sha256 = "73c58bc6ec8bb5d730c344ac6074c8cf64c448877befdf2997b4b08b14f81db5", urls = ["https://github.com/samhowes/rules_msbuild/releases/download/0.0.17/rules_msbuild-0.0.17.tar.gz"], ) load("@rules_msbuild//dotnet:deps.bzl", "msbuild_register_toolchains", "msbuild_rules_dependencies") msbuild_rules_dependencies() # See https://dotnet.microsoft.com/download/dotnet for valid versions msbuild_register_toolchains(version = "host") # bzl:generated end load("//:deps/nuget.bzl", "nuget_deps") # gazelle:nuget_macro deps/nuget.bzl%nuget_deps nuget_deps() ```