When programmatically building a .vcxproj in .NETCORE, target evaluation fails due to missing namespace in Microsoft.Build.Utilities.Core.dll
- Dominant language
- C#
- Stars
- 5.5k
- Forks
- 1.5k
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 133
Description
### Issue Description
Building a .vcxproj programmatically from a c# .netcore program fails due to a namespace that only exists in the framework version of the .dll
ERROR C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\MSBuild\\Microsoft\\VC\\v160\\Microsoft.CppCommon.targets(192,5): The \"GetOutOfDateItems\" task failed unexpectedly.
System.TypeLoadException: Could not load type 'Microsoft.Build.Utilities.CanonicalTrackedOutputFiles' from assembly 'Microsoft.Build.Utilities.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
at Microsoft.Build.CPPTasks.GetOutOfDateItems.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask)
### Steps to Reproduce
Using the following packages:
.csproj
\
\
\
\
C#
(.nuget\packages\microsoft.build\16.9.0\lib\netcoreapp2.1\Microsoft.Build.dll)
// construct a project/projectCollection object with the appropriate env variables by setting Environment.SetVariable...
// In .netcore, the registry and .exe.config options for building a ProjectCollection are ifdef'ed out
var isSuccess = project.Build(new string[] { "Rebuild" }, new ILogger[] { logger }
.vcxproj
\
\
\
\
\Debug
\Win32
\
\
\
\16.0
\Win32Proj
\{03d14b07-50ba-4cf4-b9e3-9c5f240fdef8}
\SimpleProject
\10.0
\
\
\
\
\
\
### Expected Behavior
The target evaluates without failing, or there is a shim dll to include from another nuget package to resolve the issue
### Actual Behavior
Target evaluation fails due to the dll load failure
### Analysis
This failure makes sense because the CanonicalTrackedOutputFiles class only exists in the .netframework version of the dll because FEATURE_FILE_TRACKER is only defined when building that configuration.
https://github.com/dotnet/msbuild/blob/9bcc06cbe19ae2482ab18eab90a82fd079b26897/src/Utilities/TrackedDependencies/CanonicalTrackedOutputFiles.cs
#if FEATURE_FILE_TRACKER
namespace Microsoft.Build.Utilities
{
/// \
/// This class is the filetracking log interpreter for .write. tracking logs in canonical form
/// Canonical .write. logs need to be rooted, since the outputs need to be associated with an input.
/// \
public class CanonicalTrackedOutputFiles
{
.....
However, I would expect some way to get around this missing class when trying to programmatically build in my .netcore app, or for the api to throw a notSupportedException if the scenario is not supposed to be supported.
### Versions & Configurations
Microsoft (R) Build Engine version 16.9.0+5e4b48a27 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.
16.9.0.16703
### Attach a binlog
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.