0

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.

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.

The line in the deployment command is:

"%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]

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?

Bryant
  • 8,660
  • 1
  • 33
  • 53
  • try publish using the specified project.json: dotnet publish ~/projects/app1/project.json – Set Oct 07 '16 at 08:41
  • So change the MSBuild task to not deploy on build and then manually deploy? That might work but it seems like there has got to be a way to specify which project to deploy. – Bryant Oct 07 '16 at 16:18

1 Answers1

1

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

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.

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

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

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

Bryant
  • 8,660
  • 1
  • 33
  • 53