VSTS fails to build my really really simple ASP.NE

2019-02-20 04:21发布

The following is so so simply and yet it fails. What's wrong?

  • I create a new ASP.NET Core Web Application (.NET Framework 4.6.2) in Visual Studio 2017.

  • I make no changes to the default template and I push it to VSTS.

  • I create a new build definition in VSTS with the following two steps:

    1. NuGet Restore
    2. Visual Studio Build
  • I update the NuGet step to use version 4.0.0

  • I update the definition to use the Hosted VS2017 agent.

  • I leave the Build step using VS2017 with the default MSBuild arguments:

/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\\".

In previous versions this would create me a web deployment package which is exactly what I want.

  • I queue a new build.

The NuGet step succeeds.

The build step runs until it logs...

_TransformWebConfig:

...and then...

No web.config found. Creating 'C:\a\1\s\src\WebApp\obj\Release\net462\win7-x86\PubTmp\Out\web.config'

...and...

Microsoft.NET.Sdk.Publish.MSDeployPackage.targets(124,7): Error MSB4184: The expression "[System.IO.Path]::GetDirectoryName('')" cannot be evaluated. The path is not of a legal form.

3条回答
萌系小妹纸
2楼-- · 2019-02-20 04:49

I think the follwing article has the answer.

https://www.visualstudio.com/en-us/docs/build/apps/aspnet/aspnetcore-to-azure.

In summary, don't use Visual Studio to do the build, use the CLI instead, i.e.

dotnet.exe publish -c $(BuildConfiguration) -o $(Build.ArtifactStagingDirectory)

查看更多
爷、活的狠高调
3楼-- · 2019-02-20 04:58

This issue has been fixed: https://github.com/aspnet/websdk/issues/106

Sample commandline and syntax to use in VSTS (ASPNET Core templates should already have this in the template): https://github.com/vijayrkn/ASPNetPublishSamples/blob/bff9f78d796668dc07d5e28a8b93531caade839c/Publish.cmd#L102-L127

查看更多
疯言疯语
4楼-- · 2019-02-20 05:06

You can use ASP.NET Core (Preview) build template, it publishes the .Net Core app through dotnet tool.

  1. Create a new build definition
  2. Select ASP.NET Core (Preview) build template
查看更多
登录 后发表回答