Sdk: Build fail after update to latest RC2/RC Refresh

Created on 13 Dec 2016  路  24Comments  路  Source: dotnet/sdk

As requested by @morrisjoe

I previously created this issue: https://github.com/dotnet/coreclr/issues/8602

Basically build works if you use dotnet cli only. When using Visual Studio 2017 (besides it crash a lot) it fail to build and multitarget is not working...

To reproduce:

  1. dotnet new -> Any console app build fail with the error in the previously mentioned issue while building from VS2017
  2. You can check our "updated/simplified" csproj by trying to build https://github.com/galvesribeiro/orleans/blob/codegen-core/vNext/src/ClientGenerator/ClientGenerator.csproj

The error is basically:

1>------ Build started: Project: ConsoleApp2, Configuration: Debug Any CPU ------
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Sdk.targets(127,7): error MSB4131: The "FilesWritten" parameter is not supported by the "GenerateRuntimeConfigurationFiles" task. Verify the parameter exists on the task, and it is a gettable public instance property.
1>Done building project "ConsoleApp2.csproj" -- FAILED.
========== Build: 0 succeeded or up-to-date, 1 failed, 0 skipped ==========
Bug

Most helpful comment

+1 on this issue.
I'm also facing this issue.

All 24 comments

This sounds like a mismatch in the version of the SDK task. Is a msbuild process from the previous install still running maybe (msbuild hangs around for a bit in case it needs to build again). Another possibility is that in your project you have some project references. Have all those project refs been converted to SDK form as well. Specifically if those proejcts still have a PackageReference to Microsoft.NET.Sdk then that could explain the mismatch.

@srivatsn I can check all our projects in Orleans. However, like I said, that happens with brand new project created by dotnet new.

Regarding msbuild instances, I think it is not possible since right after the update of VS2017, it asked me to reboot, and I did it.

Again, lets ignore Orleans project for now... A simple dotnet new, dotnet build works perfectly but if I try to build the project on VS2017, that error happens.

Can you build from the command line in a developer command prompt using msbuild (instead of dotnet)?

Yeah, from the command line it build fine using MSBuild. However from VS2017 same problem :(

image

@galvesribeiro I see you have two projects. Are they both new? Do both include a <Project Sdk="..."> attribute?

Just to be sure:

<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp1.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <Compile Include="**\*.cs" />
    <EmbeddedResource Include="**\*.resx" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.NETCore.App" Version="1.0.1" />
  </ItemGroup>

</Project>

Ignore the class library, I was just testing if that problem happens as well with a class library but no, it doesn't. It only happen with VS2017 and Console App projects... I also tried to update to netcoreapp1.1 but it still the same problem...

To recap:

  • VS2017: issue
  • CLI: no issue
  • MSBuild: no issue

Yup! If you need to debug with me on my machine I can share my screen in a skype for business session if you want but like I said, it is very specific to VS2017 + Console App.

Class library, CLI, MSBuild, VSCode, all that work just fine (even with Console Apps).

@dsplaisted can you take a look at this with @galvesribeiro?

@galvesribeiro Can you send me an email at daplaist at microsoft.com so we can get connected on Skype and debug this?

Sorry @dsplaisted it was late yesterday. I'm adding your alias on SfB so we can talk there.

+1 on this issue.
I'm also facing this issue.

This happens when there are MSBuild processes running that have loaded the tasks from the earlier version of the .NET SDK. If you kill all MSBuild.exe processes that are running, this should fix the issue.

Yep, looks like this is indeed the problem. I'll keep watching this.

For now, I'm closing the issue. In case we hit it again for other steps I'll ping you guys here.

Thank you for the support.

I am still having this issue with a new xUnit test project that I added to my web project after the 12/12 update.

Ended up just recreating the whole project with the latest update.

Experience this issue as well and killing all msbuild process (taskkill /F /IM msbuild.exe) doesn't help me. Run the project successfully for 30 minutes ago...

Edit: Running the solution on macOSX was less error prone but on the other side VS didn't function that well

Edit2: Unloading and reloading the project resulated in error

````

2016-12-14 10:04:11
Crippling
System.AggregateException: One or more errors occurred. ---> System.InvalidOperationException: Could not resolve mscorlib for target framework '.NETCoreApp,Version=v1.1'. This can happen if the target framework is not installed or if the framework moniker is incorrectly formatted.
at Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkUniverse..ctor(IDesignTimeAssemblyLoader assemblyLoader, IVsFrameworkMultiTargeting globalAssemblyResolution, String targetMoniker, IVsSmartOpenScope dispenser)
at Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkUniverse.GetUniverse(IDesignTimeAssemblyLoader assemblyLoader, IVsFrameworkMultiTargeting globalAssemblyResolution, String targetMoniker, IVsSmartOpenScope dispenser)
at Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkProvider..ctor(IVsFrameworkMultiTargeting targetInfo, IDesignTimeAssemblyLoader assemblyLoader, String targetMoniker, TypeDescriptionProvider parentProvider, IVsSmartOpenScope openScope)
at Microsoft.VisualStudio.ProjectUtilities.GetGlobalTargetFrameworkProvider(IServiceProvider provider)
at Microsoft.VisualStudio.Design.VSTypeResolutionService.get_TypeProvider()
at Microsoft.VisualStudio.Design.VSTypeResolutionService.VSLangProj._dispReferencesEvents.ReferenceAdded(Reference r)
at VSLangProj._dispReferencesEvents_ReferenceAddedEventHandler.Invoke(Reference pReference)
at Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.Automation.OAVSReferences.OnReferenceAdded(Reference reference)
at Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.ReferencesHostBridge.ApplyAsync(ReferencesDelta value)
at Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.ProjectHostBridge3.<>c__DisplayClass36_1.<<InitializeCoreAsync>b__3>d.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.VisualStudio.Threading.JoinableTask.<JoinAsync>d__76.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.VisualStudio.Threading.JoinableTask1.d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.ProjectHostBridge3.<>c__DisplayClass36_0.<<InitializeCoreAsync>b__2>d.MoveNext() --- End of inner exception stack trace --- ---> (Inner Exception #0) System.InvalidOperationException: Could not resolve mscorlib for target framework '.NETCoreApp,Version=v1.1'. This can happen if the target framework is not installed or if the framework moniker is incorrectly formatted. at Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkUniverse..ctor(IDesignTimeAssemblyLoader assemblyLoader, IVsFrameworkMultiTargeting globalAssemblyResolution, String targetMoniker, IVsSmartOpenScope dispenser) at Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkUniverse.GetUniverse(IDesignTimeAssemblyLoader assemblyLoader, IVsFrameworkMultiTargeting globalAssemblyResolution, String targetMoniker, IVsSmartOpenScope dispenser) at Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkProvider..ctor(IVsFrameworkMultiTargeting targetInfo, IDesignTimeAssemblyLoader assemblyLoader, String targetMoniker, TypeDescriptionProvider parentProvider, IVsSmartOpenScope openScope) at Microsoft.VisualStudio.ProjectUtilities.GetGlobalTargetFrameworkProvider(IServiceProvider provider) at Microsoft.VisualStudio.Design.VSTypeResolutionService.get_TypeProvider() at Microsoft.VisualStudio.Design.VSTypeResolutionService.VSLangProj._dispReferencesEvents.ReferenceAdded(Reference r) at VSLangProj._dispReferencesEvents_ReferenceAddedEventHandler.Invoke(Reference pReference) at Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.Automation.OAVSReferences.OnReferenceAdded(Reference reference) at Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.ReferencesHostBridge.ApplyAsync(ReferencesDelta value) at Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.ProjectHostBridge3.<>c__DisplayClass36_1.<b__3>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.Threading.JoinableTask.d__76.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.Threading.JoinableTask1.<JoinAsync>d__3.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.ProjectHostBridge3.<>c__DisplayClass36_0.<b__2>d.MoveNext()<---
````

Edit3: So unload/reload seemed to set <OutputType>winexe<OutputType> and bustled with luanchsettings.json (project name was removed for iisexpress section).
Also removed all code related to user secrets and now it works again. Don't know what conclusion I can deduct from all this. Random errors is the most suitable I think

Edit4: The build works but the login has stopped working. IIS creates a redirect loop to login and it faults due to the length of query string.. This worked earlier this morning..

Edit5: Restarted VS and now when I build I'm back at square one with the FilesWritten issue.

````

dotnet build
C:\Program Filesdotnet\sdk\1.0.0-preview4-004233\Sdks\Microsoft.NET.Sdk\build\Microsoft.PackageDependencyResolution.targets(140,5): error MSB4062: The "Microsoft.NET.Build.Tasks.ResolvePackageDependencies" task could not be loaded from the assembly C:\Program Filesdotnet\sdk\1.0.0-preview4-004233\Sdks\Microsoft.NET.Sdk\build..\tools\netcoreapp1.0/Microsoft.NET.Build.Tasks.dll. Assembly with same name is already loaded Confirm that the declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. [C:...\src\App\App.csproj]
C:\Program Filesdotnet\sdk\1.0.0-preview4-004233\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Sdk.targets(119,5): error MSB4062: The "GenerateRuntimeConfigurationFiles" task could not be loaded from the assembly C:\Program Filesdotnet\sdk\1.0.0-preview4-004233\Sdks\Microsoft.NET.Sdk\build..\tools\netcoreapp1.0/Microsoft.NET.Build.Tasks.dll. Assembly with same name is already loaded Confirm that the declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. [C:...\src\App\App.csproj]
````

The new project format doesn't work at all with Visual Studio preview for Mac. Now both development environments are out of the game.

More one issue #493

I'm still getting this error:

Severity Code Description Project File Line Suppression State
Error MSB4131 The "FilesWritten" parameter is not supported by the "GenerateRuntimeConfigurationFiles" task. Verify the parameter exists on the task, and it is a gettable public instance property. MyApp D:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Sdk.targets 127

It oddly comes and goes. I have the latest VS2017 RC and I was profiling some code (building multiple times over and over) and after about 20 recompiles the error appeared. VS2017 had focus the entire time, it just started reporting this error and will no longer compile until I exit VS2017 and restart it.

This is the 2nd time in the last few hours that I've had it happen and it did not happen until the last update.

I have a minimal .NET Core Console App referencing a .NET Core Library and I'm running the App with a combination of "Start Without Debugging" and "Start Debugging" if that helps.

I think I've fixed my issues. There was a UnitTest project using the older xml project style. After updating it to the new style it seems to be compiling properly again.

I just ran into this issue as well for an asp.net core application. I managed to fix it by changing the SDK property to this:

<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">

This gave me errors about no entry point for application. Then I changed it back to:

<Project Sdk="Microsoft.NET.Sdk.Web" ToolsVersion="15.0">

and suddenly it started working again.

@Roblinde I'm with this precise error here https://github.com/dotnet/sdk/issues/493

No matter if I change the Sdk on project root...

I had this issue, basically I had other projects with different MSBuild Tools versions. Make sure all of your projects in your solution have the new Sdk="" syntax for setting the tools and taht they are the same version and you should be good.

I am also facing the same issue. I changed to
but no luck. It is using the target at location Also C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Roslyn

Was this page helpful?
0 / 5 - 0 ratings