Error MSB3030 Could not copy the file "C:\Users\...\WebApi3\obj\Debug\netcoreapp3.0\webapi3.exe" because it was not found
Asked Answered
H

5

6

Hi Stackoverflow Community,

I am trying to build my Web and WebAPI, console applications with Target Framework - .NET Core 3.0, as per project 'Application' properties, using:

Microsoft Visual Studio Community 2019 Version 16.5.4 on Windows 10 PRO

I am seeing the following errors:

Error MSB3030 Could not copy the file "C:\Users...\WebApi3\obj\Debug\netcoreapp3.0\webapi3.exe" because it was not found

and

Error MSB3030 Could not copy the file "C:\Users...\Web\obj\Debug\netcoreapp3.0\webportal.exe" because it was not found

Hence these projects are not getting built.

Appreciate your time for reading this.

Please advise.

Here is the part of the code where the error points to:

    ============================================================
                                        _CopyOutOfDateSourceItemsToOutputDirectory

    Copy files that have the CopyToOutputDirectory attribute set to 'PreserveNewest'.
    ============================================================
    -->
  <Target
      Name="_CopyOutOfDateSourceItemsToOutputDirectory"
      Condition=" '@(_SourceItemsToCopyToOutputDirectory)' != '' "
      Inputs="@(_SourceItemsToCopyToOutputDirectory)"
      Outputs="@(_SourceItemsToCopyToOutputDirectory->'$(OutDir)%(TargetPath)')">

    <!--
        Not using SkipUnchangedFiles="true" because the application may want to change
        one of these files and not have an incremental build replace it.
        -->
    <Copy
        SourceFiles = "@(_SourceItemsToCopyToOutputDirectory)"
        DestinationFiles = "@(_SourceItemsToCopyToOutputDirectory->'$(OutDir)%(TargetPath)')"
        OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)"
        Retries="$(CopyRetryCount)"
        RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"
        UseHardlinksIfPossible="$(CreateHardLinksForAdditionalFilesIfPossible)"
        UseSymboliclinksIfPossible="$(CreateSymbolicLinksForAdditionalFilesIfPossible)"
            >

      <Output TaskParameter="DestinationFiles" ItemName="FileWrites"/>

    </Copy>

  </Target>

Hitchcock answered 12/5, 2020 at 15:31 Comment(3)
The main issue is not what you provided. The info is not enough. I think it is that the custom copy task under the main project has some errors. How did you build three projects? Did you actually build WebApi project and Web project? What is the role of custom Copy task? Did it to copy some files into a new project? You can choose Tools-->Options-->Projects and Solutions-->Build and Run-->set MSBuild project build output verbosity to Detailed to see the detailed build log to check the error.Haunt
I think your custom copy task has error. First, make sure that the output file generates before you execute the copy task. Second, make sure that the copy task command has no grammar mistakes. Or if your main project references these two projects? Or please share the content of the xxxx.csproj project file which the error locks on with us to troubleshoot this issue more quickly.Haunt
Thanks for your quick responses. Yesterday, I updated VS to 16.5.5 and both of the projects rebuild now.Hitchcock
H
4

Updating Visual Studio to 16.5.5. seems to have solved the issue so far.

Hitchcock answered 15/5, 2020 at 3:47 Comment(0)
A
9

I faced the same issue in VS2022(17.0.1) as well. I performed below steps based on a github issue [https://github.com/dotnet/sdk/issues/3122] discussion and my issue got resolved. I believe this works for VS2019 as well.

Step1: Clean Local Nuget Cache ..\projectDir> dotnet nuget locals all --clear

Step2: remove bin and Obj folders ..\projectDir> rd \s \q bin obj

Step3: Clean the solution using Visual studio build menu

Step4: Rebuild Project

Antipathy answered 3/12, 2021 at 12:26 Comment(3)
This worked in VS 2022 ASP.net core 3.1. Thanks much.Shiner
In an Azure DevOps Server pipeline with basic cleaning configured, git clean -ffdx runs at the start, so only the NuGet caches cleaning part is relevant. I ran it on all our agents and it helped.Dia
Deleting all bin and obj folders did the trick for me.Cogency
H
4

Updating Visual Studio to 16.5.5. seems to have solved the issue so far.

Hitchcock answered 15/5, 2020 at 3:47 Comment(0)
A
2

I had a similar issue but whilst attempting to publish. The affected .DLL was a nuget package and I noticed I had an update for it.

Updating the affected package, cleaning the solution, rebuilding then re-publishing resolved my issue.

Apteral answered 5/5, 2021 at 16:0 Comment(0)
M
0

For CoreXT repos by default only outputs under obj for retail builds or objd for debug builds are collected. You seem to be using the retail bridge and using obj(Debug|Release) and bin (the MSBuild non-CoreXT defaults), so those outputs are not being collected.

To remedy this, you can set the -UsePredictedOutputPath QuickBuild flag which will avoid collecting those hard-coded paths and instead ask each project what its $(IntermediateOutputPath) and $(OutputPath) are and use those.

Note that in either case, outputs under output roots (eg /target) are always collected. This flag only affects the project-relative outputs.

Montymonument answered 27/5, 2022 at 18:11 Comment(0)
C
0

For me, the issue was caused by the environment variables, there is an AppConfig variable set in the windows environment variable, removing this variable fix the issue. Hope it helps someone else.

Calix answered 13/6, 2024 at 7:49 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Melva

© 2022 - 2025 — McMap. All rights reserved.