msbuild: Net 6 Preview changes project behaviour and lead to Compile errors for projects containing dlls as content (which i use for nuget internal package packages)
Issue Description
Pack broke after update to the latest dotnet preview. Building the projekt shown below failes to compile (and pack). This is related to include dll’s marked as content via wildcard pattern. The seem to be somehow considered durig the build and are changning the framework and dll resolution.
i now see:
error CS1069: The type name 'ProcessStartInfo' could not be found in the namespace 'System.Diagnostics'. This type has been forwarded to assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' Consider adding a reference to that assembly.
error CS0103: The name 'Process' does not exist in the current context
Steps to Reproduce
Consider the following project setup. With this setup you will need to have some programm containing a self contained publish of another programm which is in my case a code generator i wrote. Of interest here is that its multi framework project against net471 and netstandard2.0.
<Project Sdk="Microsoft.NET.Sdk" >
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net471</TargetFrameworks>
</PropertyGroup>
<PropertyGroup>
<OutputPath>tasks</OutputPath>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Build.Framework" Version="16.4.0" />
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="16.4.0" />
<!-- Marks all packages as 'local only' so they don't end up in the nuspec. -->
<PackageReference Update="@(PackageReference)" PrivateAssets="All" />
</ItemGroup>
<ItemGroup>
<Content Include="../CodeGenerator/bin/Release/win64/publish/*" PackagePath="generator\windows\" Link="generator\windows\%(Filename)%(Extension)" />
<Content Include="../CodeGenerator/bin/Release/linux64/publish/*" PackagePath="generator\linux\" Link="generator\linux\%(Filename)%(Extension)" />
</ItemGroup>
</Project>
From interest is also that the project includes a MsBuild Task which is bound via
<UsingTask Condition="$([MSBuild]::IsOSUnixLike()) != 'True'" TaskName="GeneratorTask" TaskFactory="TaskHostFactory" AssemblyFile="$(TaskAssembly)" />
The task contains the following stripped down code which fails to compile with the obove listed error message:
var startInfo = new ProcessStartInfo
{
FileName = GeneratorPath,
Arguments = $"-f \"{input}\" {(Debug ? "-d" : "")} -p {CommunicationProtocol} -o \"{OutputPath}\"",
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true,
CreateNoWindow = true,
};
var process = Process.Start(startInfo);
Expected Behavior
Prior to net preview 6.5 the code was compiling without error. (no changes where performed to the project or the code) Since both netstandard2.0 and net471 includes the types around ‘Process’ the error makes no sense
Actual Behavior
warning MSB3270: There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "System.Diagnostics.StackTrace", "AMD64". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.
warning MSB3270: There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "System.Diagnostics.Tracing", "AMD64". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.
warning MSB3270: There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "System", "AMD64". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Currentwarning MSB3270: There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "System.IO.Compression", "AMD64". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.
warning MSB3270: There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "System.Net.Http", "AMD64". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.
warning MSB3270: There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "System.Net.Sockets", "AMD64". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.
warning MSB3270: There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "System.Runtime.Serialization.Primitives", "AMD64". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.
warning MSB3270: There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "System.Security.Cryptography.Algorithms", "AMD64". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.
warning MSB3270: There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "System.Threading.Thread", "AMD64". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.
warning MSB3270: There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "System.Xml.XPath.XDocument", "AMD64". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.
error CS1069: The type name 'ProcessStartInfo' could not be found in the namespace 'System.Diagnostics'. This type has been forwarded to assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' Consider adding a reference to that assembly.
error CS0103: The name 'Process' does not exist in the current context
Both errors make no sense for netstandard2.0 and net471. The warnings seem to be very relevant and are only present when the dlls are added as content.
Analysis
when excluding the content dlls from the project everything compiles without errors. so it must be something about the lines
<ItemGroup>
<Content Include="../CodeGenerator/bin/Release/win64/publish/*" PackagePath="generator\windows\" Link="generator\windows\%(Filename)%(Extension)" />
<Content Include="../CodeGenerator/bin/Release/linux64/publish/*" PackagePath="generator\linux\" Link="generator\linux\%(Filename)%(Extension)" />
</ItemGroup>
Versions & Configurations
.NET SDK (reflecting any global.json):
Version: 6.0.100-preview.5.21302.13
Commit: d6380bcae7
Runtime Environment:
OS Name: Windows
OS Version: 10.0.18363
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\6.0.100-preview.5.21302.13\
Host (useful for support):
Version: 6.0.0-preview.5.21301.5
Commit: ec3e0b276b
.NET SDKs installed:
2.1.517 [C:\Program Files\dotnet\sdk]
2.1.602 [C:\Program Files\dotnet\sdk]
5.0.104 [C:\Program Files\dotnet\sdk]
5.0.300 [C:\Program Files\dotnet\sdk]
5.0.301 [C:\Program Files\dotnet\sdk]
5.0.400-preview.21277.10 [C:\Program Files\dotnet\sdk]
6.0.100-preview.5.21302.13 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.All 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.21 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.27 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.28 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.21 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.27 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.28 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.0-preview.5.21301.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.21 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.28 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.0-preview.5.21301.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.15 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.7 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.0-preview.5.21301.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft Visual Studio Professional 2019 Preview
Version 16.11.0 Preview 2.0
VisualStudio.16.Preview/16.11.0-pre.2.0+31410.223
Microsoft .NET Framework
Version 4.8.03752
Installed Version: Professional
.NET Core Debugging with WSL 2 1.0
.NET Core Debugging with WSL 2
ASP.NET and Web Tools 2019 16.11.61.6649
ASP.NET and Web Tools 2019
ASP.NET Web Frameworks and Tools 2019 16.11.61.6649
For additional information, visit https://www.asp.net/
Azure App Service Tools v3.0.0 16.11.61.6649
Azure App Service Tools v3.0.0
Azure Functions and Web Jobs Tools 16.11.61.6649
Azure Functions and Web Jobs Tools
C# Tools 3.11.0-2.21301.11+757770cf2b5fcc3ffa83db516f90f0d2366a92f0
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.
Common Azure Tools 1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.
Extensibility Message Bus 1.2.6 (master@34d6af2)
Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration.
IntelliCode Extension 1.0
IntelliCode Visual Studio Extension Detailed Info
JetBrains ReSharper 2021.1.3 Build 211.0.20210525.202743
JetBrains ReSharper package for Microsoft Visual Studio. For more information about ReSharper, visit http://www.jetbrains.com/resharper. Copyright © 2021 JetBrains, Inc.
Microsoft Azure Tools 2.9
Microsoft Azure Tools for Microsoft Visual Studio 2019 - v2.9.40609.1
Microsoft Continuous Delivery Tools for Visual Studio 0.4
Simplifying the configuration of Azure DevOps pipelines from within the Visual Studio IDE.
Microsoft JVM Debugger 1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines
Microsoft Library Manager 2.1.113+g422d40002e.RR
Install client-side libraries easily to any web project
Microsoft MI-Based Debugger 1.0
Provides support for connecting Visual Studio to MI compatible debuggers
Microsoft Visual Studio Tools for Containers 1.2
Develop, run, validate your ASP.NET Core applications in the target environment. F5 your application directly into a container with debugging, or CTRL + F5 to edit & refresh your app without having to rebuild the container.
Mono Debugging for Visual Studio 16.10.15 (552afdf)
Support for debugging Mono processes with Visual Studio.
NuGet Package Manager 5.11.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/
ProjectServicesPackage Extension 1.0
ProjectServicesPackage Visual Studio Extension Detailed Info
Razor (ASP.NET Core) 16.1.0.2122504+13c05c96ea6bdbe550bd88b0bf6cdddf8cde1725
Provides languages services for ASP.NET Core Razor.
SQL Server Data Tools 16.0.62105.11120
Microsoft SQL Server Data Tools
TypeScript Tools 16.0.30526.2002
TypeScript Tools for Microsoft Visual Studio
Visual Basic Tools 3.11.0-2.21301.11+757770cf2b5fcc3ffa83db516f90f0d2366a92f0
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.
Visual F# Tools 16.10.0-beta.21262.7+1b23bbeda88ea3cb9be9af777f4c99fa8663df81
Microsoft Visual F# Tools
Visual Studio Code Debug Adapter Host Package 1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio
Visual Studio Container Tools Extensions 1.0
View, manage, and diagnose containers within Visual Studio.
Visual Studio Tools for Containers 1.0
Visual Studio Tools for Containers
Visual Studio Tools for Unity 4.11.0.0
Visual Studio Tools for Unity
VisualStudio.DeviceLog 1.0
Information about my package
VisualStudio.Foo 1.0
Information about my package
VisualStudio.Mac 1.0
Mac Extension for Visual Studio
Xamarin 16.11.000.157 (d16-11@0e025f1)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.
Xamarin Designer 16.10.0.115 (remotes/origin/c750fbf1bde3c720d077f51640fe197c6dac7cbe@c750fbf1b)
Visual Studio extension to enable Xamarin Designer tools in Visual Studio.
Xamarin Templates 16.10.5 (355b57a)
Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms.
Xamarin.Android SDK 11.3.99.54 (main/0e5e06f)
Xamarin.Android Reference Assemblies and MSBuild support.
Mono: c633fe9
Java.Interop: xamarin/java.interop/main@a5ed891
ProGuard: Guardsquare/proguard/v7.0.1@912d149
SQLite: xamarin/sqlite/3.35.4@85460d3
Xamarin.Android Tools: xamarin/xamarin-android-tools/main@683f375
Xamarin.iOS and Xamarin.Mac SDK 14.20.0.3 (17fdcf569)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 17 (12 by maintainers)
Assigning this to myself, will try out 5.0.400 on the repro.
@BenVillalobos We can reproduce this issue on customer’s Build VisualStudio16.11.0-pre.2.0+31410.223.
If you need repro machine, please feel free to contact us.
@rob-ack The bot isn’t perfect 😉
this one’s on us to test the repro. cc @v-codyguan