© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•10mo ago•
43 replies
乙ᗰᗩᑎ350᙭

✅ [SOLVED] MSBuild Task says file does not exist

I've made a custom MSBuild task to zip up the newly created
.dll
.dll
along with relevant files for release whenever the project is built. For some reason though, it says the newly created
.dll
.dll
does not exist... When the log literally shows its existence in the exact location like two line up:
CopyFilesToOutputDirectory:
  Copying file from "/home/newmaz/Documents/HFF_ObjectGrabber/build/obj/ObjectGrabber/Debug/Debug/ObjectGrabber.dll" to "/home/newmaz/Documents/HFF_ObjectGrabber/build/bin/output/ObjectGrabber.dll".
  ObjectGrabber -> /home/newmaz/Documents/HFF_ObjectGrabber/build/bin/output/ObjectGrabber.dll
ZipOutput:
  Zipping build
  File copied: /home/newmaz/Documents/HFF_ObjectGrabber/src/../README.md
  File copied: /home/newmaz/Documents/HFF_ObjectGrabber/src/../icon.png
  File copied: /home/newmaz/Documents/HFF_ObjectGrabber/src/../manifest.json
/home/newmaz/Documents/HFF_ObjectGrabber/src/ObjectGrabber.csproj(34,5): error : File does not exist: /home/newmaz/Documents/HFF_ObjectGrabber/src/../build/bin/output/ObjectGrabber.dll
CopyFilesToOutputDirectory:
  Copying file from "/home/newmaz/Documents/HFF_ObjectGrabber/build/obj/ObjectGrabber/Debug/Debug/ObjectGrabber.dll" to "/home/newmaz/Documents/HFF_ObjectGrabber/build/bin/output/ObjectGrabber.dll".
  ObjectGrabber -> /home/newmaz/Documents/HFF_ObjectGrabber/build/bin/output/ObjectGrabber.dll
ZipOutput:
  Zipping build
  File copied: /home/newmaz/Documents/HFF_ObjectGrabber/src/../README.md
  File copied: /home/newmaz/Documents/HFF_ObjectGrabber/src/../icon.png
  File copied: /home/newmaz/Documents/HFF_ObjectGrabber/src/../manifest.json
/home/newmaz/Documents/HFF_ObjectGrabber/src/ObjectGrabber.csproj(34,5): error : File does not exist: /home/newmaz/Documents/HFF_ObjectGrabber/src/../build/bin/output/ObjectGrabber.dll

Like, it just copied the file into the exact location it's complaining about

Here's the relevant snippet of the ZipTask:
foreach (ITaskItem input_file in Files)
{
    string file_string = input_file.ItemSpec;
    if (File.Exists(file_string))
    {
        string file_to_zip = Path.Combine(directory_to_zip, Path.GetFileName(file_string));
        File.Copy(file_string, file_to_zip, true);
        Log.LogMessage("File copied: " + file_string);
    }
    else
    {
        Log.LogError("File does not exist: " + file_string);
        return false;
    }
}
foreach (ITaskItem input_file in Files)
{
    string file_string = input_file.ItemSpec;
    if (File.Exists(file_string))
    {
        string file_to_zip = Path.Combine(directory_to_zip, Path.GetFileName(file_string));
        File.Copy(file_string, file_to_zip, true);
        Log.LogMessage("File copied: " + file_string);
    }
    else
    {
        Log.LogError("File does not exist: " + file_string);
        return false;
    }
}

And here's the part of my project's
.csproj
.csproj
that calls it:
  <UsingTask TaskName="ObjectGrabberBuildTasks.ZipTask"
             AssemblyFile="$(RootDir)\tasks\build\bin\tasks\ZipTask.dll"/>

  <Target Name="ZipOutput"
          AfterTargets="CopyFilesToOutputDirectory">
  
    <ItemGroup>
      <ZipFiles Include="$(RootDir)\README.md" />
      <ZipFiles Include="$(RootDir)\icon.png" />
      <ZipFiles Include="$(RootDir)\manifest.json" />
      <ZipFiles Include="$(OutputPath)$(AssemblyName).dll" />
    </ItemGroup>  
            
    <Message Importance="high" Text="Zipping build" />

    <ZipTask Files="@(ZipFiles)"
             OutputName="GrabCountTracker"
             OutputLocation="$(SharedBuildDir)"
    />
  </Target>
  <UsingTask TaskName="ObjectGrabberBuildTasks.ZipTask"
             AssemblyFile="$(RootDir)\tasks\build\bin\tasks\ZipTask.dll"/>

  <Target Name="ZipOutput"
          AfterTargets="CopyFilesToOutputDirectory">
  
    <ItemGroup>
      <ZipFiles Include="$(RootDir)\README.md" />
      <ZipFiles Include="$(RootDir)\icon.png" />
      <ZipFiles Include="$(RootDir)\manifest.json" />
      <ZipFiles Include="$(OutputPath)$(AssemblyName).dll" />
    </ItemGroup>  
            
    <Message Importance="high" Text="Zipping build" />

    <ZipTask Files="@(ZipFiles)"
             OutputName="GrabCountTracker"
             OutputLocation="$(SharedBuildDir)"
    />
  </Target>

Yes, I'm aware that there's no
\
\
between the
$(OutputPath)
$(OutputPath)
and
$(AssemblyName)
$(AssemblyName)
, the
$(OutputPath)
$(OutputPath)
property has the
\
\
included, and you can tell in the error message that it's successfully adding a
/
/
between the directory and file name.

Any thoughts?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Custom msbuild task
C#CC# / help
16mo ago
✅ BuildServiceProvider does not exist
C#CC# / help
2y ago
✅ Apparently the file thats right there does not exist???
C#CC# / help
14mo ago
creating a nuget for a custom msbuild task
C#CC# / help
17mo ago