question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MSBuild fails with System.InvalidOperationException: Project outputs could not be located

See original GitHub issue

Build 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:closed
  • Created 4 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

8reactions
RicoSutercommented, Jul 1, 2019

Did you also use the configuration variable in the config file?

{
  "runtime": "NetCore22",
  "defaultVariables": null,
  "documentGenerator": {
    "aspNetCoreToOpenApi": {
      "project": "NSwag.Sample.NETCore22.csproj",
      "msBuildProjectExtensionsPath": null,
      "configuration": "$(Configuration)",
0reactions
manpatel3107commented, Jun 16, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found