Sdk: Microsoft.DotNet.Common.Targets failing after upgrade

Created on 28 Oct 2016  路  13Comments  路  Source: dotnet/sdk

Summary

I upgraded my tools and project to the latest (1.0.1) and everything stops working when I build and run. My project now has build errors from Microsoft.DotNet.Common.Targets.

My solution has 2 class library project I directly reference and one mostly standard MVC project.

Steps to reproduce

Upgraded a project to version 1.0.1

Expected behavior

The project should run fine

Actual behavior

Severity Code Description Project File Line Suppression State
Error 3. You may be trying to publish a library, which is not supported. Use dotnet pack to distribute libraries. Foundation.Server C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Common.Targets 262
Error 2. The project does not list one of 'win10-x64, win81-x64, win8-x64, win7-x64' in the 'runtimes' section. Foundation.Server C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Common.Targets 262
Error 1. The project has not been restored or restore failed - run dotnet restore Foundation.Server C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Common.Targets 262
Error Can not find runtime target for framework '.NETCoreApp,Version=v1.0' compatible with one of the target runtimes: 'win10-x64, win81-x64, win8-x64, win7-x64'. Possible causes: Foundation.Server C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Common.Targets 262

Environment data

dotnet --info output:

.NET Command Line Tools (1.0.0-preview2-003121)

Product Information:
Version: 1.0.0-preview2-003121
Commit SHA-1 hash: 1e9d529bc5

Runtime Environment:
OS Name: Windows
OS Version: 10.0.10586
OS Platform: Windows
RID: win10-x64

Microsoft.Dotnet.Targets

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

  <UsingTask TaskName="DesignTimeHostBuild" AssemblyFile="$(MSBuildThisFileDirectory)Microsoft.DotNet.Tasks.dll"/>
  <UsingTask TaskName="GetSDKToolingInfo" AssemblyFile="$(MSBuildThisFileDirectory)Microsoft.DotNet.Tasks.dll"/>
  <UsingTask TaskName="Dnx" AssemblyFile="$(MSBuildThisFileDirectory)Microsoft.DotNet.Tasks.dll"/>
  <UsingTask TaskName="GetRuntimeVersion" AssemblyFile="$(MSBuildThisFileDirectory)Microsoft.DotNet.Tasks.dll"/>
  <UsingTask TaskName="DefaultExternalToolsPath" AssemblyFile="$(MSBuildThisFileDirectory)Microsoft.DotNet.Tasks.dll"/>
  <UsingTask TaskName="GetBuildOptions" AssemblyFile="$(MSBuildThisFileDirectory)Microsoft.DotNet.Tasks.dll"/>
  <UsingTask TaskName="GetDotNetProjectDependencies" AssemblyFile="$(MSBuildThisFileDirectory)Microsoft.DotNet.Tasks.dll"/>
  <UsingTask TaskName="GenerateDependencyFragmentFile" AssemblyFile="$(MSBuildThisFileDirectory)Microsoft.DotNet.Tasks.dll"/>
  <UsingTask TaskName="GetTransitiveNonDotNetProjectDependencies" AssemblyFile="$(MSBuildThisFileDirectory)Microsoft.DotNet.Tasks.dll"/>  

  <UsingTask TaskName="GetBuiltProjectOutputGroup" AssemblyFile="$(MSBuildThisFileDirectory)Microsoft.DotNet.Tasks.dll"/>


  <PropertyGroup>
    <!-- Disable common capabilities that come from Microsoft.Common.Targets. Must be done prior to the Import -->
    <DefineCommonCapabilities>false</DefineCommonCapabilities>

    <!-- The project file should have paths set for these, but if not we default to the standard paths under the project -->
    <BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
    <OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>

    <!-- DNX only produces assemblies -->
    <OutputType>Library</OutputType>

    <!-- The output assembly is the name of the directory the project is in -->
    <AssemblyName>$([System.IO.Path]::GetFileName('$(MSBuildProjectDirectory)'))</AssemblyName>

  </PropertyGroup>

  <Import Project="$(MSBuildToolsPath)\Microsoft.Common.Targets" />

  <PropertyGroup>
    <!-- This property returns "the" project output for this project, as is seen in traditional MSBuild projects like csproj or vbproj.
         Since DotNet projects have multiple target outputs, there is nothing meaningful we can return. Microsoft.Common.Targets defaults
         this property to a meaningless value, which gets picked up by ResolveProjectReferences if you have a csproj/vbproj -> xproj reference.
         We don't want that to happen, so this ensures ResolveProjectReferences will no-op in such a scenario. -->
    <TargetPath></TargetPath>

  </PropertyGroup>

  <PropertyGroup>
    <_ParentDirectoryContainingGlobalJson>$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), 'global.json'))</_ParentDirectoryContainingGlobalJson>
    <_RelativeDirectoryToRealOutput Condition="'$(_ParentDirectoryContainingGlobalJson)' == ''">$(MSBuildProjectName)</_RelativeDirectoryToRealOutput>
    <_RelativeDirectoryToRealOutput Condition="'$(_ParentDirectoryContainingGlobalJson)' != ''">$([MSBuild]::MakeRelative($(_ParentDirectoryContainingGlobalJson),$(MSBuildProjectDirectory)))</_RelativeDirectoryToRealOutput>
  </PropertyGroup>

  <!-- Returns the full target path being built by this project, including the configuration-specific folder. -->
  <Target Name="GetTargetDir" Returns="$(TargetDir)\$(_RelativeDirectoryToRealOutput)\bin\$(Configuration)" />

  <!-- Capabilities for this project.  Conditions should be based on platform|configuration only. -->
  <ItemGroup>
    <ProjectCapability Include="AllTargetOutputGroups" />
    <ProjectCapability Include="VisualStudioWellKnownOutputGroups" />
    <ProjectCapability Include="OutputGroups" />
    <ProjectCapability Include="ProjectJsonConfigurations" />
    <ProjectCapability Include="DNX" />   <!--this is for backwards compat for identifying K projects -->
    <ProjectCapability Include="DotNetCore" />
    <ProjectCapability Include="DotNetProject" />
    <ProjectCapability Include="ReferencesFolder"/>
    <ProjectCapability Include="RelativePathDerivedDefaultNamespace"/>
    <ProjectCapability Include="CSharp"/>
    <ProjectCapability Include="TypeScript"/>
    <ProjectCapability Include="SingleFileGenerators" />
    <ProjectCapability Include="FileSystemBasedDotnetProject" />
  </ItemGroup>

   <!-- Want to fallback to en-us xaml rules if rules for the current Langname are not install. Unfotuantely, just fixing $(LangName) works for msbuild command line
        but doesn't work when CPS loads the rules. So instead, all the rules are duplicated with the appropriate condition.
    -->

  <ItemGroup>
    <PropertyPageSchema Include="$(MSBuildThisFileDirectory)$(LangName)\general.xaml;" Condition="Exists('$(MSBuildThisFileDirectory)$(LangName)\general.xaml')">
      <Context>Project</Context>
    </PropertyPageSchema>
    <PropertyPageSchema Include="$(MSBuildThisFileDirectory)en-us\general.xaml;" Condition="!Exists('$(MSBuildThisFileDirectory)$(LangName)\general.xaml')">
      <Context>Project</Context>
    </PropertyPageSchema>

    <PropertyPageSchema Include="$(MSBuildThisFileDirectory)$(LangName)\ProjectItemsSchema.xaml;" Condition="Exists('$(MSBuildThisFileDirectory)$(LangName)\ProjectItemsSchema.xaml')"/>
    <PropertyPageSchema Include="$(MSBuildThisFileDirectory)en-us\ProjectItemsSchema.xaml;" Condition="!Exists('$(MSBuildThisFileDirectory)$(LangName)\ProjectItemsSchema.xaml')"/>

    <PropertyPageSchema Include="$(MSBuildThisFileDirectory)$(LangName)\debugger_general.xaml;" Condition="Exists('$(MSBuildThisFileDirectory)$(LangName)\debugger_general.xaml')">
      <Context>Project</Context>
    </PropertyPageSchema>
    <PropertyPageSchema Include="$(MSBuildThisFileDirectory)en-us\debugger_general.xaml;" Condition="!Exists('$(MSBuildThisFileDirectory)$(LangName)\debugger_general.xaml')">
      <Context>Project</Context>
    </PropertyPageSchema>

    <PropertyPageSchema Include="$(MSBuildThisFileDirectory)$(LangName)\ProjectDebugger.xaml" Condition="Exists('$(MSBuildThisFileDirectory)$(LangName)\ProjectDebugger.xaml')">
      <Context>Project</Context>
    </PropertyPageSchema>
    <PropertyPageSchema Include="$(MSBuildThisFileDirectory)en-us\ProjectDebugger.xaml" Condition="!Exists('$(MSBuildThisFileDirectory)$(LangName)\ProjectDebugger.xaml')">
      <Context>Project</Context>
    </PropertyPageSchema>

    <PropertyPageSchema Include="$(MSBuildThisFileDirectory)$(LangName)\general_file.xaml" Condition="Exists('$(MSBuildThisFileDirectory)$(LangName)\general_file.xaml')">
      <Context>File</Context>
    </PropertyPageSchema>
    <PropertyPageSchema Include="$(MSBuildThisFileDirectory)en-us\general_file.xaml" Condition="!Exists('$(MSBuildThisFileDirectory)$(LangName)\general_file.xaml')">
      <Context>File</Context>
    </PropertyPageSchema>

    <PropertyPageSchema Include="$(MSBuildThisFileDirectory)$(LangName)\scc.xaml" Condition="Exists('$(MSBuildThisFileDirectory)$(LangName)\scc.xaml')">
      <Context>Invisible</Context>
    </PropertyPageSchema>
    <PropertyPageSchema Include="$(MSBuildThisFileDirectory)en-us\scc.xaml" Condition="!Exists('$(MSBuildThisFileDirectory)$(LangName)\scc.xaml')">
      <Context>Invisible</Context>
    </PropertyPageSchema>

    <PropertyPageSchema Include="$(MSBuildThisFileDirectory)$(LangName)\csharp.xaml;" Condition="Exists('$(MSBuildThisFileDirectory)$(LangName)\csharp.xaml')">
      <Context>File</Context>
    </PropertyPageSchema>
    <PropertyPageSchema Include="$(MSBuildThisFileDirectory)en-us\csharp.xaml;" Condition="!Exists('$(MSBuildThisFileDirectory)$(LangName)\csharp.xaml')">
      <Context>File</Context>
    </PropertyPageSchema>

    <!--
       Note: Keep in mind that different Contexts associated with a xaml rule file, have different expectations
          in terms of how many files can be specified:
            - For BrowseObject context a unique file should be specified for each data source type:
                * <DataSource Persistence="ProjectFile" Label="Configuration" HasConfigurationCondition="false" />
                  is a project level datasource associated with the project itself
                * <DataSource Persistence="ProjectFile" HasConfigurationCondition="False" ItemType="Content" />
                  is a project level data source associated only with Content item types

                so if you specify another xaml rule that duplicate ItemType or has no item type specified (i.e.
                rule for project itself) there will be runtime error and no browse object properties at all.

            - For Project context as many xaml rules can be defined as needed.

      BrowseObject properties are used in properties pane (F4) and via DTE.Project.Properties.Item("prop name").

      If in other project system based on DotNet you would need to override some xaml rules
      that should have Context=BrowseObject, make sure you move it out of this file to Microsoft.DotNet.Targets.
      Browse files should be unique per Persistence + ItemType in DataSource, thus to override, each project system
      targets should define their own BrowseObject files.

      Keep in mind, all overriden xaml files should be kept in sync with core dotnet xaml files to enable properties
      that were added to core xaml rules, otherwise some core functionality might be broken.

      !!!Note!!! Never call directly members of generated cs file for BrowseObject xaml files, since if they are overriden
      in other project system, there will be type mismatch. Overriden files should have their own names for xaml Rule,
      which would end up into different generated class.
    -->
    <PropertyPageSchema Include="
                        $(MSBuildThisFileDirectory)$(LangName)\Content.xaml;
                        $(MSBuildThisFileDirectory)$(LangName)\folder.xaml;
                        $(MSBuildThisFileDirectory)$(LangName)\none.xaml;
                        $(MSBuildThisFileDirectory)$(LangName)\EmbeddedResource.xaml;
                        $(MSBuildThisFileDirectory)$(LangName)\typescript.xaml;" Condition="Exists('$(MSBuildThisFileDirectory)$(LangName)\Content.xaml')">
      <Context>File;BrowseObject</Context>
    </PropertyPageSchema>
    <PropertyPageSchema Include="
                        $(MSBuildThisFileDirectory)en-us\Content.xaml;
                        $(MSBuildThisFileDirectory)en-us\folder.xaml;
                        $(MSBuildThisFileDirectory)en-us\none.xaml;
                        $(MSBuildThisFileDirectory)en-us\EmbeddedResource.xaml;
                        $(MSBuildThisFileDirectory)en-us\typescript.xaml;" Condition="!Exists('$(MSBuildThisFileDirectory)$(LangName)\Content.xaml')">
      <Context>File;BrowseObject</Context>
    </PropertyPageSchema>

    <PropertyPageSchema Include="$(MSBuildThisFileDirectory)$(LangName)\ResolvedDesignTimeHostReferences.xaml;" Condition="Exists('$(MSBuildThisFileDirectory)$(LangName)\ResolvedDesignTimeHostReferences.xaml')">
      <Context>ProjectSubscriptionService;BrowseObject</Context>
    </PropertyPageSchema>
   <PropertyPageSchema Include="$(MSBuildThisFileDirectory)en-us\ResolvedDesignTimeHostReferences.xaml;" Condition="!Exists('$(MSBuildThisFileDirectory)$(LangName)\ResolvedDesignTimeHostReferences.xaml')">
      <Context>ProjectSubscriptionService;BrowseObject</Context>
    </PropertyPageSchema>

    <PropertyPageSchema Include="$(MSBuildThisFileDirectory)$(LangName)\csharp.browseobject.xaml;" Condition="Exists('$(MSBuildThisFileDirectory)$(LangName)\csharp.browseobject.xaml')">
      <Context>BrowseObject</Context>
    </PropertyPageSchema>
    <PropertyPageSchema Include="$(MSBuildThisFileDirectory)en-us\csharp.browseobject.xaml;" Condition="!Exists('$(MSBuildThisFileDirectory)$(LangName)\csharp.browseobject.xaml')">
      <Context>BrowseObject</Context>
    </PropertyPageSchema>
  </ItemGroup>
  <PropertyGroup>
    <DefaultContentType Condition="$(DefaultContentType) == ''">Default</DefaultContentType>
  </PropertyGroup>

  <!-- The local debugger command was set to an (empty) TargetPath before.  Now if this property is still empty,
       set it again now that TargetPath is defined. -->
  <PropertyGroup>
    <!--<LocalDebuggerCommand Condition="'$(LocalDebuggerCommand)' == ''">$(TargetPath)</LocalDebuggerCommand>-->
    <!-- We need to set this property otherwise it will try to copy our outputs, which we don't have-->
    <CopyBuildOutputToOutputDirectory>false</CopyBuildOutputToOutputDirectory>

    <!-- Avoid picking up explicit references like system.core.dll. Setting the first property is not sufficient as the common targets
         unconditionally adds the contents of AddtionalExplicitAssemblyReferences - so that property is cleared too -->
    <AddAdditionalExplicitAssemblyReferences>false</AddAdditionalExplicitAssemblyReferences>
    <AdditionalExplicitAssemblyReferences></AdditionalExplicitAssemblyReferences>
    <ProduceOutputsOnBuild Condition="'$(ProduceOutputsOnBuild)' == ''">False</ProduceOutputsOnBuild>
  </PropertyGroup>

  <Target Name="GetSDKToolingInfoTarget" >
    <GetSDKToolingInfo ProjectFolder="$(MSBuildProjectDirectory)" DesiredSDKToolingDirectory ="$(SDKToolingDirectory)">
      <!-- Path to the versioned runtime folder -->
      <Output PropertyName="SDKToolingDirectory" TaskParameter="SDKToolingDirectory"></Output>

      <!-- The full path to the sdk executable dotnet.exe -->
      <Output PropertyName="SDKToolingExe" TaskParameter="SDKToolingExe"></Output>

      <!-- The runtime package version string -->
      <Output PropertyName="SDKToolingVersion" TaskParameter="SDKToolingVersion"></Output>

      <!-- Type of SDK: DNX or DotNetCore -->
      <Output PropertyName="SDKToolingIdentifier" TaskParameter="SDKToolingIdentifier"></Output>
    </GetSDKToolingInfo>
  </Target>

  <Target
    Name="BuiltProjectOutputGroup"
    Returns="@(_BuiltProjectOutputGroupOutput)"
    DependsOnTargets="$(BuiltProjectOutputGroupDependsOn)">

    <GetBuiltProjectOutputGroup
      ProjectDirectory="$(MSBuildProjectDirectory)"
      ProjectName="$(MSBuildProjectName)"
      ProjectConfiguration="$(Configuration)"
      OutDirectory="$(OutDir)">

      <Output ItemName="_BuiltProjectOutputGroupOutput" TaskParameter="BuiltOutputGroup"></Output>
    </GetBuiltProjectOutputGroup>
  </Target>

  <!-- Without these targets, builds which include Microsoft.Common.Targets fail -->
  <Target Name="CreateManifestResourceNames" />
  <Target Name="ResolveAssemblyReferences" />

  <Target
    Name="CoreCompile"
    DependsOnTargets="GetSDKToolingInfoTarget">

  <PropertyGroup>
    <OutDirNoSlash>$(OutDir.TrimEnd('\'))</OutDirNoSlash>
    <_DesignTimeHostBuild Condition="'$(UseDesignTimeHostBuild)' == 'true' And '$(ProduceOutputsOnBuild)' != 'true'">true</_DesignTimeHostBuild>

  </PropertyGroup>


    <!-- Use either the external design time host process or run KLR to do the build and produce outputs. Note that it is
         important that the working directory is set to the project folder. This ensures any relative paths are relative to the
         project.
    -->

    <GetBuildOptions
        Configuration="$(Configuration)"
        ProjectDirectory ="$(MSBuildProjectDirectory)"
        OutDirectory ="$(OutDirNoSlash)"
        IntermediateDirectory ="$(IntermediateOutputPath)"
        RuntimeToolingDirectory ="$(SDKToolingDirectory)"
        RuntimeToolingVersion ="$(SDKToolingVersion)"
        RuntimeIdentifier ="$(RuntimeIdentifier)"
        Rebuild = "$(RebuildInvoked)"
        Condition="'$(_DesignTimeHostBuild)' != 'true'"
    >
      <Output PropertyName="_BuildArguments" TaskParameter="BuildArguments"></Output>
    </GetBuildOptions>

    <Dnx
      RuntimeExe="$(SDKToolingExe)"
      Condition="'$(_DesignTimeHostBuild)' != 'true'"
      ProjectFolder="$(MSBuildProjectDirectory)"
      Arguments="$(_BuildArguments)"
      />

    <DesignTimeHostBuild
      Condition="'$(_DesignTimeHostBuild)' == 'true'"
      Port="$(DTHPort)"
      HostID="$(DTHHostID)"
      ContextID="$(DTHContextID)"
      DTHProtocolVersion="$(DTHProtocolVersion)"
      Rebuild ="$(RebuildInvoked)"
    />
  </Target>

  <!-- This is used to set a property which indicates that the rebuild target was invoked -->
  <PropertyGroup>
    <BuildDependsOn>
      _BeforeBuild;
      $(BuildDependsOn);
    </BuildDependsOn>

    <RebuildDependsOn>
      _BeforeRebuild;
      $(RebuildDependsOn);
    </RebuildDependsOn>
  </PropertyGroup>

  <Target
      Name="_BeforeBuild"
      Returns="$(TargetPath)"
      DependsOnTargets="_GetDependencyFragmentFiles;_InjectDotNetProjectDependencies" />

  <Target
      Name="_BeforeRebuild"
      Returns="$(TargetPath)"
      DependsOnTargets="_BeforeBuild">

      <PropertyGroup>
        <RebuildInvoked>true</RebuildInvoked>
      </PropertyGroup>
  </Target>

  <!--
    This target discovers and injects all xproj dependenices of current project as ProjectRefernces.
    It uses same discovery logic as runtime does usiing global.json and current project.json.
  -->
  <Target Name="_InjectDotNetProjectDependencies">
    <GetDotNetProjectDependencies ProjectFile="$(MSBuildProjectFullPath)">
       <!-- Collection of discovered dotnet project references -->
      <Output ItemName="_DotNetProjectReference" TaskParameter="DotNetProjectReferences"></Output>
    </GetDotNetProjectDependencies>

    <!-- Now add all dotnet project references to existing project references collection -->
    <ItemGroup>
      <ProjectReference Include="@(_DotNetProjectReference)" />
    </ItemGroup>
  </Target>

  <!-- 
    This target is called before build and calls a target _GenerateDependencyFragmentFile injected to 
    all csproj project dependencies to produce a fragment lock file containing compile and runtime 
    information about given csproj project reference.
  -->
  <Target Name="_GetDependencyFragmentFiles">
    <!-- Modify ProjectReference collection to add transitive csproj dependencies from project.lock.json file. -->
    <GetTransitiveNonDotNetProjectDependencies
      ProjectFullPath="$(MSBuildProjectFullPath)"
      DirectProjectReferences="@(ProjectReference)">

      <Output ItemName="_AllNonDotNetProjectReferences" TaskParameter="AllNonDotNetProjectReferences"></Output>
    </GetTransitiveNonDotNetProjectDependencies>

    <!-- Generate json strings list containing csproj projects information -->
    <MSBuild
      Projects="@(_AllNonDotNetProjectReferences)"
      Targets="_GenerateDependencyFragmentJson">

      <Output ItemName="_FragmentLockJsons" TaskParameter="TargetOutputs"></Output>
    </MSBuild>

    <!--
      After we received json string for all non xproj projects, merge them and write to
      project.fragment.lock.json
    -->
    <GenerateDependencyFragmentFile
      ProjectFullPath="$(MSBuildProjectFullPath)"
      FragmentLockJsons="@(_FragmentLockJsons)">

      <Output ItemName="_DependencyFragmentLockFile" TaskParameter="DependencyFragmentLockFile"></Output>
    </GenerateDependencyFragmentFile>
  </Target>

  <!-- Debugger support -->
  <PropertyGroup>
    <DebuggerFlavor>ProjectDebugger</DebuggerFlavor>
  </PropertyGroup>

  <!-- Publish support -->
  <Import Project="$(MSBuildThisFileDirectory)\Microsoft.DotNet.Publishing.targets" Condition="Exists('$(MSBuildThisFileDirectory)\Microsoft.DotNet.Publishing.targets')" />

  <!-- Dynamic items support. This file will never exist on disk -->
  <Import Project="$(MSBuildProjectDirectory)\_internalAspNetSourceItems.Targets" Condition="'$(_InternalTargetsFileReady)' == 'true' and Exists('$(MSBuildProjectDirectory)\_internalAspNetSourceItems.Targets')"/>

</Project>

Line 262

 <Dnx
      RuntimeExe="$(SDKToolingExe)"
      Condition="'$(_DesignTimeHostBuild)' != 'true'"
      ProjectFolder="$(MSBuildProjectDirectory)"
      Arguments="$(_BuildArguments)"
      />

Project.json

{
  "dependencies": {
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
    "Microsoft.Extensions.Configuration.FileExtensions": "1.0.0",
    "Microsoft.Extensions.Configuration.Json": "1.0.0",
    "Microsoft.Extensions.Logging": "1.0.0",
    "Microsoft.Extensions.Logging.Console": "1.0.0",
    "Microsoft.Extensions.Logging.Debug": "1.0.0",
    "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
    "Microsoft.AspNetCore.WebSockets.Server": "0.1.0",
    "Microsoft.EntityFrameworkCore": "1.0.1",
    "Microsoft.AspNetCore.Diagnostics": "1.0.0",
    "System.AppDomain": "2.0.11",
    "Microsoft.AspNetCore.Cryptography.KeyDerivation": "1.0.0",
    "System.IdentityModel.Tokens.Jwt": "5.0.0",
    "Microsoft.AspNetCore.Authentication.JwtBearer": "1.0.0",
    "NETCore.MailKit": "1.0.0",
    "Microsoft.EntityFrameworkCore.Sqlite": "1.0.1",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
    "Microsoft.EntityFrameworkCore.InMemory": "1.0.1",
    "Microsoft.AspNetCore.Mvc": "1.0.1",
    "Microsoft.NETCore.App": "1.0.1",
    "Foundation": "1.0.0-*",
    "Foundation.Networking": "1.0.0-*"
  },

  "tools": {
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
  },

  "frameworks": {
    "netcoreapp1.0": {
      "imports": [
        "netstandard1.6",
        "dotnet5.6",
        "portable-net45+win8"
      ]
    }
  },

  "buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true
  },

  "runtimeOptions": {
    "configProperties": {
      "System.GC.Server": true
    }
  },

  "publishOptions": {
    "include": [
      "wwwroot",
      "Views",
      "Areas/**/Views",
      "appsettings.json",
      "web.config"
    ]
  },

  "scripts": {
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
  }
}

Most helpful comment

You need to change

"Microsoft.NETCore.App": "1.0.1",
to

    "Microsoft.NETCore.App": {
      "version": "1.0.1",
      "type": "platform"  
    }

Or, if you want to publish a self-contained application, you need to add a runtimes section.

All 13 comments

You need to change

"Microsoft.NETCore.App": "1.0.1",
to

    "Microsoft.NETCore.App": {
      "version": "1.0.1",
      "type": "platform"  
    }

Or, if you want to publish a self-contained application, you need to add a runtimes section.

I ended up uninstalling everything and reinstalling and it worked.

I think there were some version miss matches.

I tried a visual studio repair but don't work...

@cedrox can you open a new issue with details of what you are seeing? This issue is several releases old. If you're seeing problems with recent builds then I'd love to understand the scenario so we have a chance to address it.

This just happened to me.
1) VS 2015 Update 3
2) I installed the latest .NET Core 1.01 (https://www.microsoft.com/net/core#windowsvs2015)
3) My EntityFramework wasn't working nicely, so I updated it: Install-Package Microsoft.EntityFrameworkCore
4) Which lead to some conflict in versions with warning NU1012: Dependency conflict. Microsoft.EntityFrameworkCore 1.1.0 expected Microsoft.Extensions.Logging >= 1.1.0 but received 1.0.0 No parameterless constructor was found on 'ApplicationDbContext'.Either add a parameterless constructor to 'ApplicationDbContext' or add an implementation of 'IDbContextFactory' in the same assembly as 'ApplicationDbContext'.
5) So I tried to update all packages using the PM Update
6) It updated, but trashed my project.json - I had to add the platform bit "Microsoft.NETCore.App": {
"version": "1.0.1",
"type": "platform"
},
7) Then there were loads of errors - so I changed the version to "1.1.0". And then nothing worked....

I've attached my Project.json.

I've rolled back... And am trying to work through the EF pain.
project.json.txt

@JamesJoyceGit about the state of your uploaded project.json: the problem with it is that you have used the Microsoft.NETCore.App package in version 1.1.0 but have specified netcoreapp1.0 as framework. This doesn't play nicely with the project.json based tooling, so if you really want to update to .net core 1.1, you also need to change the framework to netcoreapp1.1 so that it will run as expected.
(This, however, is probably not the cause of your dependency conflicts)

Also happened to me.
VS 2015 Update 3.
project.json is not getting updated when upgrading Nuget packages; upgraded Microsoft.NETCore.App to v1.1.0 and got the microsoft.dotnet.common.targets (line 262) errors.

Had to manually change:

"Microsoft.NETCore.App": "1.0.1",
to

{
    "Microsoft.NETCore.App": {
      "version": "1.1.0",
      "type": "platform"  
    }

I feel that this should be basic functionality.

I feel that this should be basic functionality.

It is and with the move to csproj with VS 2017, you will no longer need to even add/update references to Microsoft.NETCore.App or NETStandard.Library - specifying the target framework(s) will do the right thing automatically.

this happened to me in one of my projects in my solution. all others compiled correctly just one gives me this build error after upgrading from rc1 to 1.1
..Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Common.Targets(262,5): error : c:\work\proj\Trunk\Gsb\Gsbr.Weberror CS2007: Unrecognized option: '-'
i have the version settings correct as others mentioned, still no idea why the compilation fails
i have posted the question here with project.json.
http://stackoverflow.com/questions/42398607/dotnetcore-1-1-application-compilation-error-cs2007-unrecognized-option-w

I changed:

"Microsoft.NETCore.App": "1.0.1",
to

"Microsoft.NETCore.App": {
  "version": "1.1.0",
  "type": "platform"  
}

the problem resolved!
Thanks

I'm getting this error when configuring EF to use migrations.
I did all changes I read here.

My environment below.

dotnet --info
.NET Command Line Tools (1.0.0-preview2-003131)

Product Information:
Version: 1.0.0-preview2-003131
Commit SHA-1 hash: 635cf40e58

Runtime Environment:
OS Name: Windows
OS Version: 6.1.7601
OS Platform: Windows
RID: win7-x64

"Microsoft.NETCore.App":
{
"version": "1.0.1",
"type": "platform"
},
{
  "version": "1.0.0-*",
  "dependencies": {
    "e4m.Domain": "1.0.0-*",
    "Microsoft.EntityFrameworkCore": "1.1.0",
    "Microsoft.EntityFrameworkCore.SqlServer": "1.1.0",
    "NETStandard.Library": "1.6.1",
  },
  "frameworks": {
    "netstandard1.6": {
      "imports": [ "dotnet5.6", "portable-net45+win8" ]
    }
  },
  "tools": {
    "Microsoft.EntityFrameworkCore.Tools.DotNet": {
      "version": "1.0.0",
      "type": "platform",
      "imports": [
        "portable-net45+win8+dnxcore50",
        "portable-net45+win8"
      ]
    },
    "Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
      "version": "1.0.0",
      "type": "platform",
      "imports": [
        "portable-net45+win8+dnxcore50",
        "portable-net45+win8"
      ]
    }
  }
}


I started witnessing the Line 262 (


"Microsoft.VisualStudio.Web.CodeGeneration.Tools": "1.0.0"


Upon removing the same and rebuilding the project, the error disappeared and i was able to build my project successfully!

Another Update; The Line 262 ( I was able to fix the errors and warnings by configuring the project.json file as follows:

>

"Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
"type": "build",
"version": "1.0.0-preview2-final"
},
"Microsoft.VisualStudio.Web.CodeGenerators.Mvc": {
"type": "build",
"version": "1.0.0-preview2-final"
}
},

"tools": {
"Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
"version": "1.0.0-preview2-final",
"imports": [
"portable-net45+win8+dnxcore50",
"portable-net45+win8"
]
}


Note: Initially i was using version as 1.0.0 for "Microsoft.VisualStudio.Web.CodeGeneration.Tools" and "Microsoft.VisualStudio.Web.CodeGenerators.Mvc" which was creating the problem; When i replaced the same version with 1.0.0-preview2-final, did a project rebuild, the problem was resolved for good without the need to remove "Microsoft.VisualStudio.Web.CodeGeneration.Tools" from under Tools like a specified in my earlier comment!

Was this page helpful?
0 / 5 - 0 ratings