ASP.Net Core解决方案发布错误的项目 [英] ASP.Net Core solution publishing wrong project

查看:123
本文介绍了ASP.Net Core解决方案发布错误的项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个新的ASP.Net核心项目,并在源代码控制中进行了设置,该代码在我签入时发布到Azure.我能够正确设置所有设置,并且一切正常.

I created a new ASP.Net core project and set it up in source control which publishes to Azure when I do a check-in. I was able to get everything setup correctly and it was working fine.

但是,我随后向解决方案中添加了一个类库项目,现在MSBuild任务没有发布我的网站项目,而是尝试发布我的类库,这当然会失败.

However, I then added a class library project to the solution and now instead of publishing my website project the MSBuild task is attempting to publish my class library which of course fails.

部署命令中的行是:

"%MSBUILD_PATH%" "%DEPLOYMENT_SOURCE%\MySolution.sln" /nologo /verbosity:m /p:deployOnBuild=True;AutoParameterizationWebConfigConnectionStrings=false;Configuration=Release;UseSharedCompilation=false;publishUrl="%DEPLOYMENT_TEMP%"

然后在运行时首先构建模型项目,这很好:

And when that runs it first builds the models project which is fine:

 D:\Program Files (x86)\dotnet\dotnet.exe build "D:\home\site\repository\MySolution.Models" --configuration Release --no-dependencies

但随后它也会尝试发布该项目:

But then it attempts to publish that project as well:

D:\Program Files (x86)\dotnet\dotnet.exe publish "D:\home\site\repository\MySolution.Models" --output "D:\local\Temp\PublishTemp\MySolution.Models71" --configuration Release --no-build
D:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Publishing.targets(149,5): error : Can not find runtime target for framework '.NETStandard,Version=v1.6' compatible with one of the target runtimes: 'win8-x86, win7-x86'. Possible causes: [D:\home\site\repository\MySolution.Models\MySolution.Models.xproj]

哪个项目错误(应该是Web项目).我似乎找不到包含此设置或解决方案文件本身中的设置的任何文件.

Which is the wrong project (it should be the web project). I can't seem to find any files that contain the settings for this or the setting in the solution file itself.

要发布正确的项目,我需要做什么?

What do I need to do for this to publish the correct project?

推荐答案

我能够通过两步来解决此问题.

I was able to solve this by doing it in two steps.

首先从msbuild命令中删除deployOnBuild = True和publishUrl = [snip].这意味着此步骤将构建项目,但不进行任何发布.

First remove the deployOnBuild=True and the publishUrl=[snip] from the msbuild command. This means this step will build the project but doesn't do any publishing.

接下来,添加执行发布的新步骤.

Next add a new step that does the publish.

为此,我首先创建了一个新变量来保存dotnet.exe的位置:

To do this I first created a new variable to hold the location of the dotnet.exe:

IF DEFINED DOTNET_PATH goto DotNetPathDefined
SET DOTNET_PATH=%ProgramFiles(x86)%\dotnet\dotnet.exe
:DotNetPathDefined

然后添加以下内容以发布Web项目:

Then add the following to do the publish of the web project:

call :ExecuteCmd "%DOTNET_PATH%" publish "%DEPLOYMENT_SOURCE%\MySolution.Web" --framework netcoreapp1.0 --output "%DEPLOYMENT_TEMP%" --configuration Release --no-build
IF !ERRORLEVEL! NEQ 0 goto error

然后将所有文件发布到部署临时文件夹,然后使用KuduSync步骤进行部署.

This then publishes all the files to the deployment temp folder which then get deployed using the KuduSync step.

这篇关于ASP.Net Core解决方案发布错误的项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆