Hi,
I have an ASP.NET core web api application targeting net462 and other class libraries in the solution targets netstandard1.4. In TFS build definition I have VS2017 MSbuild step to build and publish it.
Getting this error.
C:\Program Files (x86)\Microsoft Visual Studio2017\Enterprise\MSBuild\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\PublishTargets\Microsoft.NET.Sdk.Publish.MSDeployPackage.targets(124,7): error MSB4184: The expression "[System.I
O.Path]::GetDirectoryName('')" cannot be evaluated. The path is not of a legal form.
Additional details:
Sdk version : 1.0.3
MSBuild command:
msbuild TestApplication.sln /p:platform="any cpu" /p:Configuration=Release /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:PackageLocation="$(BuildConfiguration)TestApplication.WebApi.zip" /p:CreatePackageOnPublish=true /p:DeployIisAppPath=TestApplication.WebApi
TestApplication.WebApi.csproj
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net462</TargetFramework>
<PreserveCompilationContext>true</PreserveCompilationContext>
<AssemblyName>TestApplication.WebApi</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>TestApplication.WebApi</PackageId>
</PropertyGroup>
<ItemGroup>
<None Include="App.config" />
<None Update="wwwroot\**\*">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</None>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Routing" Version="1.1.1" />
.
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net462' ">
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
</Project>
I need suggestions on resolving this issue. Do I need to add anything in the csproj to make it successful?
Suggest me few alternatives as well
@mailbala: I got the build to work by passing in an additional property based on what the error from the targets file.
/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:PackageLocation="$(build.artifactstagingdirectory)\$(BuildConfiguration).zip" /p:DesktopBuildPackageLocation="$(build.artifactstagingdirectory)\$(BuildConfiguration).zip" /p:DeployIisAppPath=netcoreWebAppVSMac
Thanks,
Madhuri
Thanks @madhurig. I am able to build now.
Most helpful comment
@mailbala: I got the build to work by passing in an additional property based on what the error from the targets file.
/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:PackageLocation="$(build.artifactstagingdirectory)\$(BuildConfiguration).zip" /p:DesktopBuildPackageLocation="$(build.artifactstagingdirectory)\$(BuildConfiguration).zip" /p:DeployIisAppPath=netcoreWebAppVSMac
Thanks,
Madhuri