MSBuild fails with System.InvalidOperationException: Project outputs could not be located
See original GitHub issueBuild log:
.NET Core SDK v2.2.300 dotnet.exe publish ProjectName.sln --configuration Test Executing file ‘application.nswag’ with variables 'Configuration=Test,OutDir=bin\Test\netcoreapp2.2'… System.InvalidOperationException: Project outputs could not be located in 'C:\BuildAgent\work\90f916f3df1af0df\ProjectName\bin\Debug\netcoreapp2.2'. Ensure that the project has been built.
It’s always Debug in path, no matter what Configuration was passed Using the recommended configuration from https://github.com/RicoSuter/NSwag/wiki/MSBuild.
See csproj (partial):
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
<TypeScriptToolsVersion>Latest</TypeScriptToolsVersion>
<IsPackable>false</IsPackable>
<SpaRoot>ClientApp\</SpaRoot>
<DefaultItemExcludes>$(DefaultItemExcludes);$(SpaRoot)node_modules\**</DefaultItemExcludes>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
<Configurations>Debug;Test;Release</Configurations>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DefineConstants>TRACE;DEBUG</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Test|AnyCPU'">
<DefineConstants>TRACE;TEST</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DefineConstants>TRACE;RELEASE</DefineConstants>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NSwag.AspNetCore" Version="13.0.3" />
<PackageReference Include="NSwag.MSBuild" Version="13.0.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
...
<Target Name="NSwag" AfterTargets="Build">
<Copy SourceFiles="@(ReferencePath)" DestinationFolder="$(OutDir)References" />
<Exec Command="$(NSwagExe_Core22) run application.nswag /variables:Configuration=$(Configuration),OutDir=$(OutDir)" />
<RemoveDir Directories="$(OutDir)References" />
</Target>
</Project>
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
NSwag build error — Project file does not exist / Unable to ...
This project used NSwag.MSBuild to generate the client on build. As per their documentation, we had an after build target: <Exec Command=”$( ...
Read more >NUKE Build: Could not find a suitable MSBuild instance ...
I have to set process tool path. I fixed it by adding the path of MSBuild.exe .SetProcessToolPath(@"C:\Program Files\Microsoft Visual ...
Read more >Visual Studion 2022 Version 17.6 Hangs on Build\Clean ...
I noticed, that the main output (EXE) from the app is hold by the System process (PID 4 on my machine) and can't...
Read more >NSwag build error - Project file does not exist / Unable to ...
System.InvalidOperationException: Unable to retrieve project metadata. Ensure it's an MSBuild-based .NET Core project.
Read more >MSBuild No outputs for project [x] were provided, but the ...
The installer builds fine within VS IDE, but when I try to build it with MSBuild it fails with the following message: No...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Did you also use the configuration variable in the config file?
I’m seeing a similar issue where x64 is missing from the project path Project outputs could not be located in 'C:<service-base-path>\bin\Release\netcoreapp2.2'. Ensure that the project has been built.
Any help is appreciated.