Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/visual-studio/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net Visual Studio新项目缺少文件/文件夹_Asp.net_Visual Studio_Asp.net Core_Visual Studio 2017 - Fatal编程技术网

Asp.net Visual Studio新项目缺少文件/文件夹

Asp.net Visual Studio新项目缺少文件/文件夹,asp.net,visual-studio,asp.net-core,visual-studio-2017,Asp.net,Visual Studio,Asp.net Core,Visual Studio 2017,我正在使用Visual Studio 2017创建一个新的ASP.NET核心应用程序,但创建的项目由于缺少依赖项而无法编译。根据另一位用户的建议,我运行了dotnet还原。这使得应用程序能够编译和运行,但现在我遇到了一系列版本冲突,我想消除这些冲突 下面是我如何创建项目的截图 请注意下面项目中缺少的依赖项 现在我运行dotnet restore 现在应用程序可以编译了,但是我遇到了很多版本冲突 1> Encountered conflict between 'Reference:

我正在使用Visual Studio 2017创建一个新的ASP.NET核心应用程序,但创建的项目由于缺少依赖项而无法编译。根据另一位用户的建议,我运行了
dotnet还原
。这使得应用程序能够编译和运行,但现在我遇到了一系列版本冲突,我想消除这些冲突

下面是我如何创建项目的截图

请注意下面项目中缺少的依赖项

现在我运行
dotnet restore

现在应用程序可以编译了,但是我遇到了很多版本冲突

1>  Encountered conflict between 'Reference:C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.0.0\ref\netcoreapp2.0\System.AppContext.dll' and 'Reference:C:\Program Files\dotnet\sdk\NuGetFallbackFolder\system.appcontext\4.3.0\ref\netstandard1.6\System.AppContext.dll'.  Choosing 'Reference:C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.0.0\ref\netcoreapp2.0\System.AppContext.dll' because AssemblyVersion '4.2.0.0' is greater than '4.1.0.0'.
1>  Encountered conflict between 'Reference:C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.0.0\ref\netcoreapp2.0\System.Collections.dll' and 'Reference:C:\Program Files\dotnet\sdk\NuGetFallbackFolder\system.collections\4.3.0\ref\netstandard1.3\System.Collections.dll'.  Choosing 'Reference:C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.0.0\ref\netcoreapp2.0\System.Collections.dll' because AssemblyVersion '4.1.0.0' is greater than '4.0.10.0'.
1>  Encountered conflict between 'Reference:C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.0.0\ref\netcoreapp2.0\System.Collections.Concurrent.dll' and 'Reference:C:\Program Files\dotnet\sdk\NuGetFallbackFolder\system.collections.concurrent\4.3.0\ref\netstandard1.3\System.Collections.Concurrent.dll'.  Choosing 'Reference:C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.0.0\ref\netcoreapp2.0\System.Collections.Concurrent.dll' because AssemblyVersion '4.0.14.0' is greater than '4.0.10.0'.
1>  Encountered conflict between 'Reference:C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.0.0\ref\netcoreapp2.0\System.Collections.NonGeneric.dll' and 'Reference:C:\Program Files\dotnet\sdk\NuGetFallbackFolder\system.collections.nongeneric\4.3.0\ref\netstandard1.3\System.Collections.NonGeneric.dll'.  Choosing 'Reference:C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.0.0\ref\netcoreapp2.0\System.Collections.NonGeneric.dll' because AssemblyVersion '4.1.0.0' is greater than '4.0.1.0'.
... and so on
我的两个问题是

  • 创建新的ASP核心项目后立即运行
    dotnet restore
    是否正常?如果不是,是什么导致了我的问题
  • 如何消除版本冲突
  • 更新

    如果其他人也有同样的问题,并且偶然发现这个问题,我发现由于某种原因,我的“恢复丢失的包”选项没有启用。一旦我启用了它,我就能够成功地构建我的项目,而无需首先执行
    dotnet还原

  • 没什么可怕的。绝对正常。当您在命令行调用
    dotnet build
    时,
    dotnet restore
    将被隐式调用。这是对.NETSDK2.0的更改。如果您被迫手动运行
    dotnet restore
    ,这将成为另一个问题,这意味着您的.NET核心SDK不会生效。您需要学习
    global.json
    ,并在项目中创建这样一个文件,以强制在此机器上使用最新的SDK,如 Visual Studio 2017可能要求您使用Restore NuGet Packages菜单项。 Visual Studio for Mac或JetBrains Rider将自动恢复包

  • 没有人试图摆脱它。MSBuild在计算上有其内部逻辑,并且非常清晰
  • 好好利用谷歌和GitHub,你就能找到微软公开的所有官方信息


    project.assets.json
    的存在表明
    package.json
    的遗留问题仍然存在于构建过程中。

    尝试使用命令行(在命令提示符下)
    dotnet new mvc
    dotnet new web
    创建一个虚拟应用程序。然后执行
    dotnet restore
    并运行
    dotnet run
    。如果程序运行不正常,则Dotnet SDK可能已损坏。因此,它也影响了Visual Studio 2017。如果运行良好,请尝试使用所需的依赖项更新VS2017again@o_O我尝试了你的
    dotnet restore
    建议,解决了这个问题。我在Visual Studio中运行了
    Tools->Get Tools and Features
    ,并确保在
    Workloads
    下选中了
    ASP.NET和web development
    。这就是你建议的吗?即使在那之后,我仍然有一个问题,那就是我不得不手动运行
    dotnet restore
    。这样做正常吗?在编译时,我还遇到了很多在…
    错误之间发生冲突的
    。我以前从未见过。很抱歉,我不能再帮你了。我使用VS代码而不是VS2017进行dotnet核心应用程序开发。它很轻,而且更好。除了桌面应用程序之外,从未尝试过VS2017。您使用的是过时的Visual Studio 2017或其扩展吗?我不知道。在扩展和更新下,列出的只有AWS工具包和Azure分析工具。我还刚刚下载并安装了最新版本的.NET Core SDK(2.1.3)。感谢您的解释。关于第1点,在VS中构建项目不会创建缺少的
    project.assets.json
    文件,但是
    dotnet build
    会创建。为什么呢?我想这两个是等价的?另一个问题:既然.NET Core 2使用的是.csproj而不是.json,为什么需要这个
    project.assets.json
    文件(如果需要,为什么在创建项目时Visual Studio不创建它)?