4

I am trying to build my .Net Core solution and I am getting these error messages that I can't figure out;

2017-05-22T14:30:56.2490242Z _TransformWebConfig:
2017-05-22T14:30:56.2490242Z   No web.config found. Creating 'd:\a\1\s\SIR\obj\Release\net452\win7-x86\PubTmp\Out\web.config'
2017-05-22T14:30:56.2830092Z ##[error]C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\PublishTargets\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.
2017-05-22T14:30:56.2830092Z ##[debug]Processed: ##vso[task.logissue type=Error;sourcepath=C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\PublishTargets\Microsoft.NET.Sdk.Publish.MSDeployPackage.targets;linenumber=124;columnnumber=7;code=MSB4184;]The expression "[System.IO.Path]::GetDirectoryName('')" cannot be evaluated. The path is not of a legal form.
2017-05-22T14:30:56.2830092Z C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\PublishTargets\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. [d:\a\1\s\SIR\Properties.API.csproj]
2017-05-22T14:30:56.2830092Z ##[debug]Processed: ##vso[task.logdetail id=43c372fe-1339-4917-bfb2-2d3438740b01;parentid=e8365874-6f54-4a8c-a31f-62c69bcfdb57;type=Build;result=Failed;finishtime=2017-05-22T14:30:56.2790105Z;progress=100;state=Completed;parentid=e8365874-6f54-4a8c-a31f-62c69bcfdb57;name=;]
2017-05-22T14:30:56.2830092Z Done Building Project "d:\a\1\s\SIR\Properties.API.csproj" (default targets) -- FAILED.
arame3333
  • 9,887
  • 26
  • 122
  • 205

4 Answers4

3

Refer to these steps:

  1. Add NuGet Installer (4.0.0) task to restore packages
  2. Add Visual Studio Build task (Solution: **\*.sln; MSBuild Arguments: /t:[projects] /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\\App1"). Note: projects are the general .net framework projects in that solution, such as /t:project1;project2
  3. Add .NET Core task (Command: publish; Uncheck Publish Web Projects option; Projects: $(build.sourcesdirectory)/*Core*.csproj (per to your core projects’ name); Arguments: -o "$(build.artifactstagingdirectory)\\App2"
  4. Add Publish Build Artifacts task
starian chen-MSFT
  • 33,174
  • 2
  • 29
  • 53
  • This fixed my problem, although I have a new one I am asking on another question; https://stackoverflow.com/questions/44153600/vsts-directory-d-a-1-a-is-empty-nothing-will-be-added-to-build-artifact-dr – arame3333 May 24 '17 at 09:22
  • The key correction was adding the projects into the build in point 2. – arame3333 May 24 '17 at 09:25
  • Ok, I do another commit and this bug has come up again with the same error in the same place in the log file. Surely it can't be my code changes that cause this, but what else could it be? – arame3333 Jun 29 '17 at 10:54
  • When I click on the error I see another error; Cannot find path /C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/MSBuild/Sdks/Microsoft.NET.Sdk.Publish/build/netstandard1.0/PublishTargets/Microsoft.NET.Sdk.Publish.MSDeployPackage.targets at Commit bae4ef1c, or you do not have permission – arame3333 Jun 29 '17 at 14:58
  • Do you get the error during the build? What's the detail of log file? – starian chen-MSFT Jun 30 '17 at 02:11
  • Yes, during the build. See https://1drv.ms/u/s!AhERQL5GdvI4rSuyp5_fg3gdtUTF – arame3333 Jun 30 '17 at 05:52
  • Do you add core project? Could you share the latest projects? – starian chen-MSFT Jun 30 '17 at 06:02
  • There is one Core project out of the nine shown here, and a special publish task for the Core Project. The other projects are published separately over 3 tasks so that the filter can select the correct ones. See https://1drv.ms/f/s!AhERQL5GdvI4rS4gxdWBeOmiIEPb – arame3333 Jun 30 '17 at 06:19
  • 1
    Based on the build log, it still builds Properties.API project. Do you add Properties.API project reference to SIR.WebUI? Try to create a publish profile, then publish it by using that publish profile /p:DeployOnBuild=true /p:PublishProfile="[profile name]";DesktopBuildPackageLocation="$(build.artifactstagingdirectory)\WebUI.zip" – starian chen-MSFT Jun 30 '17 at 06:36
  • OMG you are right! I do not know how it happened but there was an unused reference to Properties.API in the Sir.WebUI project. I do not know how it got there, and the error message is not at all helpful, but I now have a clean build. So thank you very much! – arame3333 Jun 30 '17 at 06:50
0

This error occurs when you build an msdeploy package using publish profile that is missing the DesktopBuildPackageLocation property.

Make sure that your publish profile includes this property, maybe also cross-check with the examples listed in the websdk repo.

For reference, a sample msdeploy package publish profile (from the link above) looks like:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <WebPublishMethod>Package</WebPublishMethod>
    <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
    <LastUsedPlatform>Any CPU</LastUsedPlatform>
    <DesktopBuildPackageLocation>c:\DeployedApp\WebDeployPackage.zip</DesktopBuildPackageLocation>
    <DeployIisAppPath>Default Web Site/WebAppWithDB</DeployIisAppPath>
  </PropertyGroup>
</Project>
Martin Ullrich
  • 94,744
  • 25
  • 252
  • 217
  • I am at the build stage at the moment, not looking at deploy until that works. So in VSTS I am using the visual interface to configure my build settings and I have not yet come across DesktopBuildPackageLocation. – arame3333 May 23 '17 at 08:11
  • well it looks something is passing `/p:DeployOnBuild=true` and a publish profile from somewhere.. so have a look at the exact build arguments – Martin Ullrich May 23 '17 at 08:35
0

I ran into the same issue with the default ASP Core template Build in VSTS. I don't have a publish profile as I am managing builds through VSTS CI templates. I found that the answer in this SO post solved my issue.

I replaced my Visual Studio Build task with the .NET Core (PREVIEW) task and used the dotnet publish command.

.Net Core Task

Build Arguments

  • My solution contains a Core Web API but also uses the .Net framework so I guess I cannot use your solution. – arame3333 May 23 '17 at 08:09
  • The VSTS task should be available for any project utilizing the .NET Core framework. The [publish](https://learn.microsoft.com/en-us/dotnet/articles/core/tools/dotnet-publish) command can also be modified to target specific frameworks. – Ikaika Tadaki May 23 '17 at 20:22
0

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

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

vijayrkn
  • 461
  • 4
  • 7
  • It is the build that is failing not the deploy – arame3333 Jun 30 '17 at 06:22
  • It is failing while building the package. This is the exact line where it was failing. The target was expecting 'DesktopBuildPackageLocation' instead of 'PackageLocation' and failing because the 'DesktopBuildPackageLocation' value was null. https://github.com/aspnet/websdk/commit/63832d9815a2152f794fb0a57ab5fc54dbdeb9cb#diff-0cc5784937d01ed918e0f724ad162fbeR143 – vijayrkn Jun 30 '17 at 15:04
  • In your case yes, but my problem - which has now been fixed thanks to @starain-MSFT is different to yours. – arame3333 Jun 30 '17 at 16:18
  • I was specifically talking about the fix for this error message . Glad to know that the issue you were running into is fixed. 2017-05-22T14:30:56.2830092Z C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\PublishTargets\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. [d:\a\1\s\SIR\Properties.API.csproj] – vijayrkn Jun 30 '17 at 16:52