While publishing an application on azure pipelines, I encounter the following problem.
/opt/hostedtoolcache/dotnet/sdk/6.0.412/Microsoft.Common.CurrentVersion.targets(5097,5): error MSB3030: Could not copy the file "/home/vsts/work/1/s/src/Api.Web/obj/Release/net6.0/win-x64/apphost.exe" because it was not found. [/home/vsts/work/1/s/src/Api.Web/Api.Web.csproj]
The associated steps are the following:
pool:
vmImage: 'windows-latest'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: UseDotNet@2
displayName: 'Setting dotnet SDK'
inputs:
packageType: 'sdk'
version: '6.x'
- task: NuGetToolInstaller@1
inputs:
versionSpec: '6.x'
- task: NuGetCommand@2
displayName: 'NuGet restore'
inputs:
command: 'restore'
restoreSolution: '$(solution)'
feedsToUse: 'select'
vstsFeed: 'c77b2597-5a55-4944-9a41-faeef2a74d81'
- task: DotNetCoreCLI@2
displayName: Build Solution
inputs:
command: 'build'
projects: '$(solution)'
arguments: '--no-restore --configuration $(buildConfiguration)'
- task: DotNetCoreCLI@2
displayName: Publish to artifactstagingdirectory
inputs:
command: publish
publishWebProjects: false
projects: |
**/Api.Web.csproj
arguments: '-f net6.0 --self-contained false --no-restore --r win-x64 --output $(Build.Artifactstagingdirectory)/$(Build.BuildNumber) --configuration $(buildConfiguration)'
zipAfterPublish: false
- task: PublishBuildArtifacts@1
displayName: Publish artifacts
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
artifactName: 'api'
And the csproj that I'm trying to publish
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>disable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<Configurations>Debug;Release;Development;Test</Configurations>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<RuntimeIdentifiers>win-x64</RuntimeIdentifiers>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
<RunAnalyzersDuringBuild>False</RunAnalyzersDuringBuild>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.*" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.*" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.*">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.*" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.*" />
<PackageReference Include="Scrutor" Version="4.*" />
</ItemGroup>
<ItemGroup>
<None Update="Microsoft.Data.SqlClient.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Api.Application\Api.Application.csproj" />
<ProjectReference Include="..\Api.Infrastructure.Persistence\Api.Infrastructure.Persistence.csproj" />
</ItemGroup>
</Project>
- Tried to remove the -r flag in dotnet publish step
- Tried to use debug configuration
- Turning --self-contained false to --no-self-contained
- Tried changing to linux vm image
All the above steps that I tried resulted in the same consistent error.