aspnet / Templates

This repo is OBSOLETE - please see the README file for information
Other
151 stars 57 forks source link

The project file could not be loaded for csproj #874

Closed ezeasharma closed 6 years ago

ezeasharma commented 6 years ago

I migrated my .netcore 1.1 proj to 2.0 using this link https://docs.microsoft.com/en-us/aspnet/core/migration/1x-to-2x/

but when i perform "dotnet restore -v d" i get the following error:

Build started 10/23/2017 19:57:01.
     1>Project "someproj.csproj" on node 1 (Restore target(s)).
     1>Building with tools version "15.0".
     1>someproj.csproj(1,1): error MSB4025: The project file could not be loaded. Data at the root level is invalid. Line 1, position 1.
     1>Done Building Project "someproj.csproj" (Restore target(s)) -- FAILED.

Build FAILED.

       "/someproj/someproj.csproj" (Restore target) (1) ->
         /someproj.csproj(1,1): error MSB4025: The project file could not be loaded. Data at the root level is invalid. Line 1, position 1.

    0 Warning(s)
    1 Error(s)

Here is the output for dotnet --info

.NET Command Line Tools (2.0.0)

Product Information:
 Version:            2.0.0
 Commit SHA-1 hash:  cdcd1928c9

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.12
 OS Platform: Darwin
 RID:         osx.10.12-x64
 Base Path:   /usr/local/share/dotnet/sdk/2.0.0/

Microsoft .NET Core Shared Framework Host

  Version  : 2.0.0
  Build    : e8b8861ac7faf042c87a5c2f9f2d04c98b69f28d

This is my csproj file


<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <TargetFramework>netcoreapp2.0</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <Folder Include="wwwroot\" />
    <Folder Include="swagger_static\" />
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
    <PackageReference Include="Serilog" Version="2.4.0" />
    <PackageReference Include="Serilog.Extensions.Logging" Version="1.4.0" />
    <PackageReference Include="Serilog.Sinks.Console" Version="2.1.0" />
    <PackageReference Include="Swashbuckle.AspNetCore" Version="1.0.0" />
    <PackageReference Include="Dapper" Version="1.50.2" />
    <PackageReference Include="System.Net.Http" Version="4.3.2" />
    <PackageReference Include="System.Threading" Version="4.3.0" />
    <PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
  </ItemGroup>
  <ItemGroup>
  <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0" />
  <DotNetCliToolReference Include="Microsoft.Extensions.SecretManager.Tools" Version="2.0.0" />
  <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />
</ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\..\..\..\recon.curator.common\recon.curator.common.csproj" />
    <ProjectReference Include="..\..\..\..\recon.curator.service\recon.curator.service.csproj" />
  </ItemGroup>
</Project>
ezeasharma commented 6 years ago

Turned out there were some special characters in the file which are not visible in VSCode. When i opened the file on Vim, it showed some unwanted characters....deleting those fixed the issue