在VSTS上,我尝试为面向.NET Framework 4.6.2的ASP.NET Core应用程序定义构建定义
我在VSTS Build上看到这两个模板,但不确定两者之间的区别是什么,我应该使用哪一个。
我试过了两个并且得到了不同的错误。哪个构建模板对我来说是一个好的开始?我的应用程序目前非常简单" Hello World"应用程序,但它确实有几个类库项目。我这样做是为了模拟我的应用在完成后会是什么样子。
所以,我的解决方案看起来像这样:
- ASP.NET核心应用程序(Targeting .NET 4.6.2)
- 类库1(针对.NET 4.6.2)
- 类库2(针对.NET 4.6.2)
两个类库都是经典类型 - 见下文
更新: 我尝试过这篇文章,这篇文章非常适用于基于.Net Core构建的ASP.NET解决方案。
https://www.visualstudio.com/en-gb/docs/build/apps/aspnet/aspnetcore-to-azure
但是,我在步骤2中遇到错误:dotnet restore:
Errors in C:\a\1\s\Dev\src\MyProject\project.json
2016-11-07T17:17:33.3792225Z Unable to resolve 'ClassLibrary1' for '.NETFramework,Version=v4.6.2'.
2016-11-07T17:17:33.3792225Z Unable to resolve 'ClassLibrary2' for '.NETFramework,Version=v4.6.2'
我需要做哪些修改才能将这些步骤应用到我的项目中?
更新2: 这是我的project.json文件
{
"dependencies": {
"Microsoft.AspNetCore.Diagnostics": "1.0.0",
"Microsoft.AspNetCore.Mvc": "1.0.1",
"Microsoft.AspNetCore.Razor.Tools": {
"version": "1.0.0-preview2-final",
"type": "build"
},
"Microsoft.AspNetCore.Routing": "1.0.1",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
"Microsoft.AspNetCore.StaticFiles": "1.0.0",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "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.VisualStudio.Web.BrowserLink.Loader": "14.0.0"
},
"tools": {
"BundlerMinifier.Core": "2.0.238",
"Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final",
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
},
"frameworks": {
"net462": {
"dependencies": {
"ClassLibrary1": {
"target": "project"
},
"ClassLibrary2": {
"target": "project"
}
}
}
},
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},
"publishOptions": {
"include": [
"wwwroot",
"**/*.cshtml",
"appsettings.json",
"web.config"
]
},
"scripts": {
"prepublish": [ ],
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
}
}
更新3: 这是构建定义中的当前任务集。这是直接来自ASP.NET Build(PREVIEW),除了我删除了测试步骤并将NuGet版本更改为3.5.0 - build 1938(rc2)。此外,MSBuild参数如下:
/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\\"