2017-03-24 129 views
0

最近,我在使用.net core 1.1進行角色2.net核心應用程序與vs 2015的工作時,最近我的Windows硬盤有點灰塵。我有一臺電腦與Ubuntu的上它,所以我雖然爲什麼不只是下載VS代碼和克隆我的項目,並得到正確的工作.....好吧,我有問題,希望有人可以幫助。試圖讓我的.net核心應用程序在Visual Studio代碼中運行

我安裝c#我安裝C#擴展。但這是我得到的錯誤

構建失敗。 /home/deshazer/Documents/code/HannaOilGas2/HannaOilAndGas2/project.json(1,1):error MSB4025:項目文件無法加載。根級別的數據無效。 1號線,位置1 0警告(S) 1個錯誤 已用時間00:00:00.06

現在我project.json文件看起來像這樣

{ 
    "dependencies": { 
    "Microsoft.NETCore.App": { 
     "version": "1.1.0", 
     "type": "platform" 
    }, 
    "Microsoft.AspNetCore": "1.1.0", 
    "Microsoft.AspNetCore.Mvc.Core": "1.1.1", 
    "Microsoft.AspNetCore.AngularServices": "1.0.0-*", 
    "Microsoft.AspNetCore.Razor.Tools": { 
     "version": "1.0.0-preview2-final", 
     "type": "build" 
    }, 
    "Microsoft.AspNetCore.Diagnostics": "1.1.0", 
    "Microsoft.AspNetCore.Mvc": "1.1.1", 
    "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0", 
    "Microsoft.AspNetCore.Server.Kestrel": "1.1.0", 
    "Microsoft.AspNetCore.StaticFiles": "1.1.0", 
    "Microsoft.Extensions.Configuration.CommandLine": "1.1.0", 
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0", 
    "Microsoft.Extensions.Configuration.Json": "1.1.0", 
    "Microsoft.Extensions.Logging": "1.1.0", 
    "Microsoft.Extensions.Logging.Console": "1.1.0", 
    "Microsoft.Extensions.Logging.Debug": "1.1.0", 
    "Microsoft.Extensions.Options.ConfigurationExtensions": "1.1.0", 
    "Microsoft.EntityFrameworkCore.SqlServer": "1.1.0", 
    "Microsoft.EntityFrameworkCore.SqlServer.Design": "1.1.0", 
    "Microsoft.EntityFrameworkCore.Tools": "1.1.0-preview4-final" 
    }, 

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

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

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

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

    "publishOptions": { 
    "include": [ 
     "appsettings.json", 
     "ClientApp/dist", 
     "node_modules", 
     "Views", 
     "web.config", 
     "wwwroot" 
    ] 
    }, 

    "scripts": { 
    "prepublish": [ 
     "npm install", 
     "node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js --env.prod", 
     "node node_modules/webpack/bin/webpack.js --env.prod" 
    ], 
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ] 
    }, 

    "tooling": { 
    "defaultNamespace": "HannaOilAndGas2" 
    } 
} 

我也看到我的模型和我的控制器的問題我使用的網絡api任何人都可以幫助我與vs代碼?

using System; 
using System.Collections.Generic; 

namespace HannaOilAndGas2.Data 
{ 
    public partial class MainView 
    { 
     public int RecId { get; set; } 
     public string Location { get; set; } 
     public double? SpotFlowRate { get; set; } 
     public double? PreviousDayVolume { get; set; } 
     public double? LinePressure { get; set; } 
     public double? DifferentialPressure { get; set; } 
     public double? Temperature { get; set; } 
     public double? BatteryVoltage { get; set; } 
     public double? Fcp { get; set; } 
     public double? Ftp { get; set; } 
     public DateTime? Timestamp { get; set; } 
     public string LastCommunicationMethod { get; set; } 
     public string MeterId { get; set; } 
     public string ImportMethod { get; set; } 
     public int HannaDeviceId { get; set; } 


    } 
} 

說類型系統無法找到,它要求我把int方法eh。

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Threading.Tasks; 
using Microsoft.AspNetCore.Mvc; 
using HannaOilAndGas2.Data; 

// For more information on enabling Web API for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860 

namespace HannaOilAndGas2.Controllers 
{ 
    [Produces("application/json")] 
    [Route("api/mainview")] 
    public class MainViewApi : Controller 
    { 
     private readonly ScadaContext _context; 

     public MainViewApi(ScadaContext context) 
     { 
      _context = context; 
     } 
     // GET: api/values 
     [HttpGet] 
     [Route("allmainview")]   //front end - done 
     public IEnumerable<MainView> GetAllMainView() 
     { 
      return _context.Main_View.Where(x => !x.MeterId.StartsWith("HOGC"));    
     } 

     [HttpGet] 
     [Route("allwinccuview")]  //front end - done 
     public IEnumerable<MainView> GetAllWinccuView() 
     { 
      return _context.Main_View.Where(x => x.ImportMethod == "WINCCU"); 
     } 

     [HttpGet] 
     [Route("allmanualview")]  //front end - done 
     public IEnumerable<MainView> GetAllManualView() 
     { 
      return _context.Main_View.Where(x => x.ImportMethod == "SPREADSHEET"); 
     } 

     [HttpGet] 
     [Route("allservicestarview")] //front end - done 
     public IEnumerable<MainView> GetAllServiceStarView() 
     { 
      return _context.Main_View.Where(x => x.ImportMethod == "SERVICESTAR-POLL"); 
     } 

     [Route("allcanadaview")]  //front end - done 
     public IEnumerable<MainView> GetAllCanadaView() 
     { 
      return _context.Main_View.Where(x => x.MeterId.StartsWith("HOGC")); 
     } 

     // GET api/values/5 
     [HttpGet("{id}")] 
     public IEnumerable<MainView> GetMainViewDataById(int id) 
     { 
      return _context.Main_View.Where(x => x.RecId == id); 
     } 

     // POST api/values 
     [HttpPost] 
     public void Post([FromBody]string value) 
     { 
     } 

     // PUT api/values/5 
     [HttpPut("{id}")] 
     public void Put(int id, [FromBody]string value) 
     { 
     } 

     // DELETE api/values/5 
     [HttpDelete("{id}")] 
     public void Delete(int id) 
     { 
     } 
    } 
} 

這話說預定義的類型系統的字符串沒有定義或再次導入netcoreapp1.1這是我project.json請任何幫助,將不勝感激。

+0

您是否在Ubuntu上使用最新的.NET Core SDK?你在終端上運行'dotnet --version'時會得到什麼?問題可能是您的應用程序使用'project.json',但您的.NET Core SDK版本正在尋找.csproj,這需要MSBuild轉換。 – kimbaudi

+0

@Set我有點網1.0.1 –

+0

我現在生成了一個.csproj,但我得到MSBUILD:錯誤MSB1009:項目文件不存在。它說這是運行時框架版本 1.1.1

回答

1

Project.json更改回.csproj。我建議你使用遷移

DOTNET migrate命令

在CLI爲你在Linux上運行您的項目。

+0

謝謝你的建議我試圖做到這一點,但現在我得到MSBuild:錯誤MSB1009:項目文件不存在 –

+0

檢查路徑,更改路徑到您的項目文件的位置 – Sriram

+0

不完全確定如何做到這一點改變了路徑我可能只是想要一臺Windows機器備份並在2015年工作。我在我的筆記本電腦上用vs 2015開啓了項目,狀況良好,能夠立即工作。考慮到我正在使用.net核心,我希望他們能夠更輕鬆地從vs 2015到vs代碼 –

相關問題