Can't publish ASP.NET Core 1.0 RC2 Application

2019-05-07 20:26发布

I don't have Visual Studio on the build server. After migrating from DNX (RC1) to .NET Core CLI (RC2) my build on TeamCity broke.

After making sure I had copied the MSBuild targets from my PC to the build server:

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet

I'm able to build the solution.

The problem is: I can't publish it!

When I run: MSBuild.exe Solution.sln /p:DeployOnBuild=true /p:publishprofile=local it will fail with:

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Publishing.targets(406,5): error : An error occurred during publish. [d:\path\project.xproj] C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Publishing.targets(406,5): error : Cannot bind argument to parameter 'Path' because it is an empty string. [d:\path\project.xproj]

I've re-created the publish profiles with Visual Studio (the powershell script generated is different than the one with the RC1)

The publish works fine locally, where I have Visual Studio installed.

The question is:

What do I need to add to the build server, to be able to run MSBuild with /p:DeployOnBuild=true /p:publishprofile= without having to install Visual Studio.

Thanks

1条回答
做个烂人
2楼-- · 2019-05-07 21:22

I won't mark this as the answer as I'm still hoping for the right answer, but to help others who got stuck like me:

What I did so far:

The project.json got:

 "publishOptions": {
    "include": [
      "appsettings.json",
      "hosting.json",
      "web.config"
    ]
  },
  "scripts": {
    "postpublish": [
      "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:project.Bla%"
    ]
  }, 

Build steps are:

  1. dotnet restore on the solution directory
  2. msbuild solution
  3. dotnet publish on the specific project directory

e.g:

d:\project\Project.Bla>dotnet publish -c Release
Publishing Project.Bla for .NETFramework,Version=v4.5.2/win7-x64
Project Project.Bla (.NETFramework,Version=v4.5.2) was previously compiled. Skipping compilation.
Project Project.Ble (.NETFramework,Version=v4.5.2) was previously compiled. Skipping compilation.
...
Configuring the following project for use with IIS: 'd:\project\Project.Bla\bin\Release\net452\win7-x64\publish'
Updating web.config at 'd:\project\Project.Bla\bin\Release\net452\win7-x64\publish\web.config'
Configuring project completed successfully
publish: Published to d:\project\Project.Bla\bin\Release\net452\win7-x64\publish
Published 1/1 projects successfully
查看更多
登录 后发表回答