0
votes

I have created ASP.NET Core project from command line:

> dotnet new web
> dotnet restore
> dotnet build
> dotnet run

All works fine.

Now I have opened this project in Visual Studio 2017.

  • Debug - Start without debugging:

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. at System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type) at System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext) at System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg) at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent) at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType) at System.Attribute.GetCustomAttributes(Assembly element, Type attributeType, Boolean inherit) at System.AppDomain.GetTargetFrameworkName()

How can I launcn, debug and develop my project in VS ?

p.s. I know I can create new project in VS and it works fine, but I need to work with project which was created from command line.

Update:

PS Q:\tsts> dotnet --version
1.0.0

PS Q:\tsts> type .\tsts.csproj
<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp1.1</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <Folder Include="wwwroot\" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore" Version="1.1.1" />
  </ItemGroup>

</Project>


PS Q:\tsts> dotnet build
Microsoft (R) Build Engine version 15.1.548.43366
Copyright (C) Microsoft Corporation. All rights reserved.

  tsts -> Q:\tsts\bin\Debug\netcoreapp1.1\tsts.dll

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:02.90
1
What is dotnetcore command? Maybe dotnet? Run dotnet --version and dotnet and show output (from dotnet - only version and build)? And add your csproj file please.Dmitry
I have updated the question.demas
Repeated your steps - VS2017 opened and runned project successfully, both via IIS Express and via project run ('Run' button dropdown). Check that "dependencies" in solution explorer are ok (no yellow signs about package restore problems). Try close VS, remove bin, obj and .vs folder and reopen - VS will re-restore packages.Dmitry
Thanks. Removing bin and obj folders helped me.demas

1 Answers

2
votes

Opening and running dotnet new project in VS2017 should work.

But sometimes VS goes crazy with strange and inexplicable "not found" dependencies and "not compiled" new files - then just close VS (or unload project), manually remove bin and obj folders and reopen project.