Remove VS2010 references to deleted files in web project












9















I went behind VS2010's back and deleted some images from an image folder that's referenced by a web project as Content. In the solution navigator, these files now show up with the yellow warning icon that the file cannot be found. Refreshing the folder has no effect. Is there a way to tell VS2010 to automatically synch a folder? The VS Website project does this by default.










share|improve this question


















  • 1





    The difference in behavior is due to the Web Application project uses the MSBuild based project system to determine what files are included (and listed in the .csproj/.vbproj), whereas the Web Site project just looks at the files system.

    – Jimmy
    Feb 6 '12 at 20:17











  • You can build the project and then you will get the list of missing files. Based on this list you are able to detect missing files and remove them.

    – starikovs
    Jul 16 '12 at 13:01
















9















I went behind VS2010's back and deleted some images from an image folder that's referenced by a web project as Content. In the solution navigator, these files now show up with the yellow warning icon that the file cannot be found. Refreshing the folder has no effect. Is there a way to tell VS2010 to automatically synch a folder? The VS Website project does this by default.










share|improve this question


















  • 1





    The difference in behavior is due to the Web Application project uses the MSBuild based project system to determine what files are included (and listed in the .csproj/.vbproj), whereas the Web Site project just looks at the files system.

    – Jimmy
    Feb 6 '12 at 20:17











  • You can build the project and then you will get the list of missing files. Based on this list you are able to detect missing files and remove them.

    – starikovs
    Jul 16 '12 at 13:01














9












9








9


1






I went behind VS2010's back and deleted some images from an image folder that's referenced by a web project as Content. In the solution navigator, these files now show up with the yellow warning icon that the file cannot be found. Refreshing the folder has no effect. Is there a way to tell VS2010 to automatically synch a folder? The VS Website project does this by default.










share|improve this question














I went behind VS2010's back and deleted some images from an image folder that's referenced by a web project as Content. In the solution navigator, these files now show up with the yellow warning icon that the file cannot be found. Refreshing the folder has no effect. Is there a way to tell VS2010 to automatically synch a folder? The VS Website project does this by default.







visual-studio visual-studio-2010






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Feb 6 '12 at 20:13









Joel RodgersJoel Rodgers

2,91842942




2,91842942








  • 1





    The difference in behavior is due to the Web Application project uses the MSBuild based project system to determine what files are included (and listed in the .csproj/.vbproj), whereas the Web Site project just looks at the files system.

    – Jimmy
    Feb 6 '12 at 20:17











  • You can build the project and then you will get the list of missing files. Based on this list you are able to detect missing files and remove them.

    – starikovs
    Jul 16 '12 at 13:01














  • 1





    The difference in behavior is due to the Web Application project uses the MSBuild based project system to determine what files are included (and listed in the .csproj/.vbproj), whereas the Web Site project just looks at the files system.

    – Jimmy
    Feb 6 '12 at 20:17











  • You can build the project and then you will get the list of missing files. Based on this list you are able to detect missing files and remove them.

    – starikovs
    Jul 16 '12 at 13:01








1




1





The difference in behavior is due to the Web Application project uses the MSBuild based project system to determine what files are included (and listed in the .csproj/.vbproj), whereas the Web Site project just looks at the files system.

– Jimmy
Feb 6 '12 at 20:17





The difference in behavior is due to the Web Application project uses the MSBuild based project system to determine what files are included (and listed in the .csproj/.vbproj), whereas the Web Site project just looks at the files system.

– Jimmy
Feb 6 '12 at 20:17













You can build the project and then you will get the list of missing files. Based on this list you are able to detect missing files and remove them.

– starikovs
Jul 16 '12 at 13:01





You can build the project and then you will get the list of missing files. Based on this list you are able to detect missing files and remove them.

– starikovs
Jul 16 '12 at 13:01












5 Answers
5






active

oldest

votes


















2














In Visual Studio go to the missing files, select them and press del (or right click and select Delete).



Save the project and you are good to go.



As you noted, this is not automatic - the project file needs to be synced up with the actual filesystem. This does not happen with website "projects" because there is no project file.






share|improve this answer


























  • I was hoping not to have to do that, but that's life.

    – Joel Rodgers
    Feb 8 '12 at 6:48











  • I was hoping not to have to do that, but that's live, unfortunatly also in new Visual Studio 2013. Next time: always delete from the project/solution, and not directly in the file explorer...

    – Langeleppel
    Dec 5 '13 at 14:16






  • 1





    in vs 2015 (not sure about older versions) there is a search bar above your project tree which you can use to filter and then multi select and hit delete once. Though this only works if all of the files you need to remove are similarly named

    – agradl
    May 7 '15 at 19:22





















2














I just had this problem in VS 2015. Files were missing all over the web project, so didn't want to go looking for them all.



The quickest way home was to: exclude all files/folders then include them all again.



That is:




  1. solution explorer -> select all files and folders -> right-click -> "Exclude from Project"

  2. solution explorer -> click "Show all Files"

  3. solution explorer -> select all files and folders -> right-click -> "Include in Project"






share|improve this answer



















  • 4





    Note that the downside of this approach is that you will also include files which you had explicitly excluded before.

    – Chris
    May 24 '16 at 12:59



















2














I've created a PowerShell script to deal with the issue.



function ExtractInclude ($line)
{
if ($line -like '*Content Include=*') {
return $line.Split('"') | select -Skip 1 | select -First 1
}
}

function RemoveMissingInclude ([string]$path, [bool]$report) {
$reader = [System.IO.File]::OpenText($path)
$projectPath = (Split-Path $path) + "/"

try {
for() {
$line = $reader.ReadLine()
if ($line -eq $null) { break }

$pathInclude = ExtractInclude($line)

if ($report) {
if ($pathInclude -ne "") {
if (-not (Test-Path "$projectPath$pathInclude")) { $pathInclude }
}
} else {
if ($pathInclude -ne "") {
if (Test-Path "$projectPath$pathInclude") { $line }
} else {
$line
}
}
}
}
finally {
$reader.Close()
}
}


Just run the following to create a cleaned up project file:



RemoveMissingInclude -path "D:pathname.csproj" | Out-File D:pathnameClean.csproj


Additional information can be found within this blog post: http://devslice.net/2017/06/remove-missing-references-visual-studio/






share|improve this answer


























  • this is nice but it does not take into account that the "<content" tag could have more that one line

    – Pedro
    Dec 6 '17 at 19:53



















0














Answering in Nov-2018 as some body like me might be facing this issue.



Problem:



I have backed up some folders in the project.



Due to files are replicas of original files, the function definitions were referenced.



And now when I try to open the function definition from function call, the one from back up folder is opening.



After deleting the back up folders, it is showing me error: xyz.php file not found, create one.



Solution:



Go to the folder in Explorer,



Click on Refresh icon.



Restart the Visual Studio Code.






share|improve this answer































    -1














    I made a very simple console app for this:



    using System;
    using System.IO;
    using System.Collections.Generic;

    namespace CleanProject
    {
    class Program
    {
    static void Main(string args)
    {
    var newFile = new List<string>();
    if (args.Length == 0)
    {
    Console.WriteLine("Please specify the project full path as an argument");
    return;
    }

    var projFile = args[0];
    if (!File.Exists(projFile))
    {
    Console.WriteLine("The specified project file does not exist: {0}", projFile);
    return;
    }

    if (!projFile.ToLowerInvariant().EndsWith(".csproj"))
    {
    Console.WriteLine("The specified does not seem to be a project file: {0}", projFile);
    return;
    }

    Console.WriteLine("Started removing missing files from project:", projFile);

    var newProjFile = Path.Combine(Path.GetDirectoryName(projFile), Path.GetFileNameWithoutExtension(projFile) + ".Clean.csproj");
    var lines = File.ReadAllLines(projFile);
    var projectPath = Path.GetDirectoryName(projFile);
    for(var i = 0; i < lines.Length; i++)
    {
    var line = lines[i];
    if (!line.Contains("<Content Include="") && !line.Contains("<None Include=""))
    {
    newFile.Add(line);
    }
    else
    {
    var start = line.IndexOf("Include="") + "Include="".Length;
    var end = line.LastIndexOf(""");
    var path = line.Substring(start, end - start);
    if (File.Exists(Path.Combine(projectPath, path)))
    {
    newFile.Add(line);
    }
    else
    {
    if (!line.EndsWith("/>")) // I'm assuming it's only one line inside the tag
    i += 2;
    }
    }
    }
    File.WriteAllLines(newProjFile, newFile);

    Console.WriteLine("Finished removing missing files from project.");
    Console.WriteLine("Cleaned project file: {0}", newProjFile);
    }
    }
    }


    https://github.com/woodp/remove-missing-project-files






    share|improve this answer

























      Your Answer






      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "1"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f9166602%2fremove-vs2010-references-to-deleted-files-in-web-project%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      5 Answers
      5






      active

      oldest

      votes








      5 Answers
      5






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      2














      In Visual Studio go to the missing files, select them and press del (or right click and select Delete).



      Save the project and you are good to go.



      As you noted, this is not automatic - the project file needs to be synced up with the actual filesystem. This does not happen with website "projects" because there is no project file.






      share|improve this answer


























      • I was hoping not to have to do that, but that's life.

        – Joel Rodgers
        Feb 8 '12 at 6:48











      • I was hoping not to have to do that, but that's live, unfortunatly also in new Visual Studio 2013. Next time: always delete from the project/solution, and not directly in the file explorer...

        – Langeleppel
        Dec 5 '13 at 14:16






      • 1





        in vs 2015 (not sure about older versions) there is a search bar above your project tree which you can use to filter and then multi select and hit delete once. Though this only works if all of the files you need to remove are similarly named

        – agradl
        May 7 '15 at 19:22


















      2














      In Visual Studio go to the missing files, select them and press del (or right click and select Delete).



      Save the project and you are good to go.



      As you noted, this is not automatic - the project file needs to be synced up with the actual filesystem. This does not happen with website "projects" because there is no project file.






      share|improve this answer


























      • I was hoping not to have to do that, but that's life.

        – Joel Rodgers
        Feb 8 '12 at 6:48











      • I was hoping not to have to do that, but that's live, unfortunatly also in new Visual Studio 2013. Next time: always delete from the project/solution, and not directly in the file explorer...

        – Langeleppel
        Dec 5 '13 at 14:16






      • 1





        in vs 2015 (not sure about older versions) there is a search bar above your project tree which you can use to filter and then multi select and hit delete once. Though this only works if all of the files you need to remove are similarly named

        – agradl
        May 7 '15 at 19:22
















      2












      2








      2







      In Visual Studio go to the missing files, select them and press del (or right click and select Delete).



      Save the project and you are good to go.



      As you noted, this is not automatic - the project file needs to be synced up with the actual filesystem. This does not happen with website "projects" because there is no project file.






      share|improve this answer















      In Visual Studio go to the missing files, select them and press del (or right click and select Delete).



      Save the project and you are good to go.



      As you noted, this is not automatic - the project file needs to be synced up with the actual filesystem. This does not happen with website "projects" because there is no project file.







      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited Feb 6 '12 at 20:20

























      answered Feb 6 '12 at 20:15









      OdedOded

      409k71744910




      409k71744910













      • I was hoping not to have to do that, but that's life.

        – Joel Rodgers
        Feb 8 '12 at 6:48











      • I was hoping not to have to do that, but that's live, unfortunatly also in new Visual Studio 2013. Next time: always delete from the project/solution, and not directly in the file explorer...

        – Langeleppel
        Dec 5 '13 at 14:16






      • 1





        in vs 2015 (not sure about older versions) there is a search bar above your project tree which you can use to filter and then multi select and hit delete once. Though this only works if all of the files you need to remove are similarly named

        – agradl
        May 7 '15 at 19:22





















      • I was hoping not to have to do that, but that's life.

        – Joel Rodgers
        Feb 8 '12 at 6:48











      • I was hoping not to have to do that, but that's live, unfortunatly also in new Visual Studio 2013. Next time: always delete from the project/solution, and not directly in the file explorer...

        – Langeleppel
        Dec 5 '13 at 14:16






      • 1





        in vs 2015 (not sure about older versions) there is a search bar above your project tree which you can use to filter and then multi select and hit delete once. Though this only works if all of the files you need to remove are similarly named

        – agradl
        May 7 '15 at 19:22



















      I was hoping not to have to do that, but that's life.

      – Joel Rodgers
      Feb 8 '12 at 6:48





      I was hoping not to have to do that, but that's life.

      – Joel Rodgers
      Feb 8 '12 at 6:48













      I was hoping not to have to do that, but that's live, unfortunatly also in new Visual Studio 2013. Next time: always delete from the project/solution, and not directly in the file explorer...

      – Langeleppel
      Dec 5 '13 at 14:16





      I was hoping not to have to do that, but that's live, unfortunatly also in new Visual Studio 2013. Next time: always delete from the project/solution, and not directly in the file explorer...

      – Langeleppel
      Dec 5 '13 at 14:16




      1




      1





      in vs 2015 (not sure about older versions) there is a search bar above your project tree which you can use to filter and then multi select and hit delete once. Though this only works if all of the files you need to remove are similarly named

      – agradl
      May 7 '15 at 19:22







      in vs 2015 (not sure about older versions) there is a search bar above your project tree which you can use to filter and then multi select and hit delete once. Though this only works if all of the files you need to remove are similarly named

      – agradl
      May 7 '15 at 19:22















      2














      I just had this problem in VS 2015. Files were missing all over the web project, so didn't want to go looking for them all.



      The quickest way home was to: exclude all files/folders then include them all again.



      That is:




      1. solution explorer -> select all files and folders -> right-click -> "Exclude from Project"

      2. solution explorer -> click "Show all Files"

      3. solution explorer -> select all files and folders -> right-click -> "Include in Project"






      share|improve this answer



















      • 4





        Note that the downside of this approach is that you will also include files which you had explicitly excluded before.

        – Chris
        May 24 '16 at 12:59
















      2














      I just had this problem in VS 2015. Files were missing all over the web project, so didn't want to go looking for them all.



      The quickest way home was to: exclude all files/folders then include them all again.



      That is:




      1. solution explorer -> select all files and folders -> right-click -> "Exclude from Project"

      2. solution explorer -> click "Show all Files"

      3. solution explorer -> select all files and folders -> right-click -> "Include in Project"






      share|improve this answer



















      • 4





        Note that the downside of this approach is that you will also include files which you had explicitly excluded before.

        – Chris
        May 24 '16 at 12:59














      2












      2








      2







      I just had this problem in VS 2015. Files were missing all over the web project, so didn't want to go looking for them all.



      The quickest way home was to: exclude all files/folders then include them all again.



      That is:




      1. solution explorer -> select all files and folders -> right-click -> "Exclude from Project"

      2. solution explorer -> click "Show all Files"

      3. solution explorer -> select all files and folders -> right-click -> "Include in Project"






      share|improve this answer













      I just had this problem in VS 2015. Files were missing all over the web project, so didn't want to go looking for them all.



      The quickest way home was to: exclude all files/folders then include them all again.



      That is:




      1. solution explorer -> select all files and folders -> right-click -> "Exclude from Project"

      2. solution explorer -> click "Show all Files"

      3. solution explorer -> select all files and folders -> right-click -> "Include in Project"







      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered Sep 17 '15 at 13:04









      dean grandedean grande

      6541012




      6541012








      • 4





        Note that the downside of this approach is that you will also include files which you had explicitly excluded before.

        – Chris
        May 24 '16 at 12:59














      • 4





        Note that the downside of this approach is that you will also include files which you had explicitly excluded before.

        – Chris
        May 24 '16 at 12:59








      4




      4





      Note that the downside of this approach is that you will also include files which you had explicitly excluded before.

      – Chris
      May 24 '16 at 12:59





      Note that the downside of this approach is that you will also include files which you had explicitly excluded before.

      – Chris
      May 24 '16 at 12:59











      2














      I've created a PowerShell script to deal with the issue.



      function ExtractInclude ($line)
      {
      if ($line -like '*Content Include=*') {
      return $line.Split('"') | select -Skip 1 | select -First 1
      }
      }

      function RemoveMissingInclude ([string]$path, [bool]$report) {
      $reader = [System.IO.File]::OpenText($path)
      $projectPath = (Split-Path $path) + "/"

      try {
      for() {
      $line = $reader.ReadLine()
      if ($line -eq $null) { break }

      $pathInclude = ExtractInclude($line)

      if ($report) {
      if ($pathInclude -ne "") {
      if (-not (Test-Path "$projectPath$pathInclude")) { $pathInclude }
      }
      } else {
      if ($pathInclude -ne "") {
      if (Test-Path "$projectPath$pathInclude") { $line }
      } else {
      $line
      }
      }
      }
      }
      finally {
      $reader.Close()
      }
      }


      Just run the following to create a cleaned up project file:



      RemoveMissingInclude -path "D:pathname.csproj" | Out-File D:pathnameClean.csproj


      Additional information can be found within this blog post: http://devslice.net/2017/06/remove-missing-references-visual-studio/






      share|improve this answer


























      • this is nice but it does not take into account that the "<content" tag could have more that one line

        – Pedro
        Dec 6 '17 at 19:53
















      2














      I've created a PowerShell script to deal with the issue.



      function ExtractInclude ($line)
      {
      if ($line -like '*Content Include=*') {
      return $line.Split('"') | select -Skip 1 | select -First 1
      }
      }

      function RemoveMissingInclude ([string]$path, [bool]$report) {
      $reader = [System.IO.File]::OpenText($path)
      $projectPath = (Split-Path $path) + "/"

      try {
      for() {
      $line = $reader.ReadLine()
      if ($line -eq $null) { break }

      $pathInclude = ExtractInclude($line)

      if ($report) {
      if ($pathInclude -ne "") {
      if (-not (Test-Path "$projectPath$pathInclude")) { $pathInclude }
      }
      } else {
      if ($pathInclude -ne "") {
      if (Test-Path "$projectPath$pathInclude") { $line }
      } else {
      $line
      }
      }
      }
      }
      finally {
      $reader.Close()
      }
      }


      Just run the following to create a cleaned up project file:



      RemoveMissingInclude -path "D:pathname.csproj" | Out-File D:pathnameClean.csproj


      Additional information can be found within this blog post: http://devslice.net/2017/06/remove-missing-references-visual-studio/






      share|improve this answer


























      • this is nice but it does not take into account that the "<content" tag could have more that one line

        – Pedro
        Dec 6 '17 at 19:53














      2












      2








      2







      I've created a PowerShell script to deal with the issue.



      function ExtractInclude ($line)
      {
      if ($line -like '*Content Include=*') {
      return $line.Split('"') | select -Skip 1 | select -First 1
      }
      }

      function RemoveMissingInclude ([string]$path, [bool]$report) {
      $reader = [System.IO.File]::OpenText($path)
      $projectPath = (Split-Path $path) + "/"

      try {
      for() {
      $line = $reader.ReadLine()
      if ($line -eq $null) { break }

      $pathInclude = ExtractInclude($line)

      if ($report) {
      if ($pathInclude -ne "") {
      if (-not (Test-Path "$projectPath$pathInclude")) { $pathInclude }
      }
      } else {
      if ($pathInclude -ne "") {
      if (Test-Path "$projectPath$pathInclude") { $line }
      } else {
      $line
      }
      }
      }
      }
      finally {
      $reader.Close()
      }
      }


      Just run the following to create a cleaned up project file:



      RemoveMissingInclude -path "D:pathname.csproj" | Out-File D:pathnameClean.csproj


      Additional information can be found within this blog post: http://devslice.net/2017/06/remove-missing-references-visual-studio/






      share|improve this answer















      I've created a PowerShell script to deal with the issue.



      function ExtractInclude ($line)
      {
      if ($line -like '*Content Include=*') {
      return $line.Split('"') | select -Skip 1 | select -First 1
      }
      }

      function RemoveMissingInclude ([string]$path, [bool]$report) {
      $reader = [System.IO.File]::OpenText($path)
      $projectPath = (Split-Path $path) + "/"

      try {
      for() {
      $line = $reader.ReadLine()
      if ($line -eq $null) { break }

      $pathInclude = ExtractInclude($line)

      if ($report) {
      if ($pathInclude -ne "") {
      if (-not (Test-Path "$projectPath$pathInclude")) { $pathInclude }
      }
      } else {
      if ($pathInclude -ne "") {
      if (Test-Path "$projectPath$pathInclude") { $line }
      } else {
      $line
      }
      }
      }
      }
      finally {
      $reader.Close()
      }
      }


      Just run the following to create a cleaned up project file:



      RemoveMissingInclude -path "D:pathname.csproj" | Out-File D:pathnameClean.csproj


      Additional information can be found within this blog post: http://devslice.net/2017/06/remove-missing-references-visual-studio/







      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited Jun 26 '17 at 8:31

























      answered Jun 25 '17 at 1:46









      Kevin BronsdijkKevin Bronsdijk

      212




      212













      • this is nice but it does not take into account that the "<content" tag could have more that one line

        – Pedro
        Dec 6 '17 at 19:53



















      • this is nice but it does not take into account that the "<content" tag could have more that one line

        – Pedro
        Dec 6 '17 at 19:53

















      this is nice but it does not take into account that the "<content" tag could have more that one line

      – Pedro
      Dec 6 '17 at 19:53





      this is nice but it does not take into account that the "<content" tag could have more that one line

      – Pedro
      Dec 6 '17 at 19:53











      0














      Answering in Nov-2018 as some body like me might be facing this issue.



      Problem:



      I have backed up some folders in the project.



      Due to files are replicas of original files, the function definitions were referenced.



      And now when I try to open the function definition from function call, the one from back up folder is opening.



      After deleting the back up folders, it is showing me error: xyz.php file not found, create one.



      Solution:



      Go to the folder in Explorer,



      Click on Refresh icon.



      Restart the Visual Studio Code.






      share|improve this answer




























        0














        Answering in Nov-2018 as some body like me might be facing this issue.



        Problem:



        I have backed up some folders in the project.



        Due to files are replicas of original files, the function definitions were referenced.



        And now when I try to open the function definition from function call, the one from back up folder is opening.



        After deleting the back up folders, it is showing me error: xyz.php file not found, create one.



        Solution:



        Go to the folder in Explorer,



        Click on Refresh icon.



        Restart the Visual Studio Code.






        share|improve this answer


























          0












          0








          0







          Answering in Nov-2018 as some body like me might be facing this issue.



          Problem:



          I have backed up some folders in the project.



          Due to files are replicas of original files, the function definitions were referenced.



          And now when I try to open the function definition from function call, the one from back up folder is opening.



          After deleting the back up folders, it is showing me error: xyz.php file not found, create one.



          Solution:



          Go to the folder in Explorer,



          Click on Refresh icon.



          Restart the Visual Studio Code.






          share|improve this answer













          Answering in Nov-2018 as some body like me might be facing this issue.



          Problem:



          I have backed up some folders in the project.



          Due to files are replicas of original files, the function definitions were referenced.



          And now when I try to open the function definition from function call, the one from back up folder is opening.



          After deleting the back up folders, it is showing me error: xyz.php file not found, create one.



          Solution:



          Go to the folder in Explorer,



          Click on Refresh icon.



          Restart the Visual Studio Code.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 22 '18 at 4:51









          PupilPupil

          19.1k43053




          19.1k43053























              -1














              I made a very simple console app for this:



              using System;
              using System.IO;
              using System.Collections.Generic;

              namespace CleanProject
              {
              class Program
              {
              static void Main(string args)
              {
              var newFile = new List<string>();
              if (args.Length == 0)
              {
              Console.WriteLine("Please specify the project full path as an argument");
              return;
              }

              var projFile = args[0];
              if (!File.Exists(projFile))
              {
              Console.WriteLine("The specified project file does not exist: {0}", projFile);
              return;
              }

              if (!projFile.ToLowerInvariant().EndsWith(".csproj"))
              {
              Console.WriteLine("The specified does not seem to be a project file: {0}", projFile);
              return;
              }

              Console.WriteLine("Started removing missing files from project:", projFile);

              var newProjFile = Path.Combine(Path.GetDirectoryName(projFile), Path.GetFileNameWithoutExtension(projFile) + ".Clean.csproj");
              var lines = File.ReadAllLines(projFile);
              var projectPath = Path.GetDirectoryName(projFile);
              for(var i = 0; i < lines.Length; i++)
              {
              var line = lines[i];
              if (!line.Contains("<Content Include="") && !line.Contains("<None Include=""))
              {
              newFile.Add(line);
              }
              else
              {
              var start = line.IndexOf("Include="") + "Include="".Length;
              var end = line.LastIndexOf(""");
              var path = line.Substring(start, end - start);
              if (File.Exists(Path.Combine(projectPath, path)))
              {
              newFile.Add(line);
              }
              else
              {
              if (!line.EndsWith("/>")) // I'm assuming it's only one line inside the tag
              i += 2;
              }
              }
              }
              File.WriteAllLines(newProjFile, newFile);

              Console.WriteLine("Finished removing missing files from project.");
              Console.WriteLine("Cleaned project file: {0}", newProjFile);
              }
              }
              }


              https://github.com/woodp/remove-missing-project-files






              share|improve this answer






























                -1














                I made a very simple console app for this:



                using System;
                using System.IO;
                using System.Collections.Generic;

                namespace CleanProject
                {
                class Program
                {
                static void Main(string args)
                {
                var newFile = new List<string>();
                if (args.Length == 0)
                {
                Console.WriteLine("Please specify the project full path as an argument");
                return;
                }

                var projFile = args[0];
                if (!File.Exists(projFile))
                {
                Console.WriteLine("The specified project file does not exist: {0}", projFile);
                return;
                }

                if (!projFile.ToLowerInvariant().EndsWith(".csproj"))
                {
                Console.WriteLine("The specified does not seem to be a project file: {0}", projFile);
                return;
                }

                Console.WriteLine("Started removing missing files from project:", projFile);

                var newProjFile = Path.Combine(Path.GetDirectoryName(projFile), Path.GetFileNameWithoutExtension(projFile) + ".Clean.csproj");
                var lines = File.ReadAllLines(projFile);
                var projectPath = Path.GetDirectoryName(projFile);
                for(var i = 0; i < lines.Length; i++)
                {
                var line = lines[i];
                if (!line.Contains("<Content Include="") && !line.Contains("<None Include=""))
                {
                newFile.Add(line);
                }
                else
                {
                var start = line.IndexOf("Include="") + "Include="".Length;
                var end = line.LastIndexOf(""");
                var path = line.Substring(start, end - start);
                if (File.Exists(Path.Combine(projectPath, path)))
                {
                newFile.Add(line);
                }
                else
                {
                if (!line.EndsWith("/>")) // I'm assuming it's only one line inside the tag
                i += 2;
                }
                }
                }
                File.WriteAllLines(newProjFile, newFile);

                Console.WriteLine("Finished removing missing files from project.");
                Console.WriteLine("Cleaned project file: {0}", newProjFile);
                }
                }
                }


                https://github.com/woodp/remove-missing-project-files






                share|improve this answer




























                  -1












                  -1








                  -1







                  I made a very simple console app for this:



                  using System;
                  using System.IO;
                  using System.Collections.Generic;

                  namespace CleanProject
                  {
                  class Program
                  {
                  static void Main(string args)
                  {
                  var newFile = new List<string>();
                  if (args.Length == 0)
                  {
                  Console.WriteLine("Please specify the project full path as an argument");
                  return;
                  }

                  var projFile = args[0];
                  if (!File.Exists(projFile))
                  {
                  Console.WriteLine("The specified project file does not exist: {0}", projFile);
                  return;
                  }

                  if (!projFile.ToLowerInvariant().EndsWith(".csproj"))
                  {
                  Console.WriteLine("The specified does not seem to be a project file: {0}", projFile);
                  return;
                  }

                  Console.WriteLine("Started removing missing files from project:", projFile);

                  var newProjFile = Path.Combine(Path.GetDirectoryName(projFile), Path.GetFileNameWithoutExtension(projFile) + ".Clean.csproj");
                  var lines = File.ReadAllLines(projFile);
                  var projectPath = Path.GetDirectoryName(projFile);
                  for(var i = 0; i < lines.Length; i++)
                  {
                  var line = lines[i];
                  if (!line.Contains("<Content Include="") && !line.Contains("<None Include=""))
                  {
                  newFile.Add(line);
                  }
                  else
                  {
                  var start = line.IndexOf("Include="") + "Include="".Length;
                  var end = line.LastIndexOf(""");
                  var path = line.Substring(start, end - start);
                  if (File.Exists(Path.Combine(projectPath, path)))
                  {
                  newFile.Add(line);
                  }
                  else
                  {
                  if (!line.EndsWith("/>")) // I'm assuming it's only one line inside the tag
                  i += 2;
                  }
                  }
                  }
                  File.WriteAllLines(newProjFile, newFile);

                  Console.WriteLine("Finished removing missing files from project.");
                  Console.WriteLine("Cleaned project file: {0}", newProjFile);
                  }
                  }
                  }


                  https://github.com/woodp/remove-missing-project-files






                  share|improve this answer















                  I made a very simple console app for this:



                  using System;
                  using System.IO;
                  using System.Collections.Generic;

                  namespace CleanProject
                  {
                  class Program
                  {
                  static void Main(string args)
                  {
                  var newFile = new List<string>();
                  if (args.Length == 0)
                  {
                  Console.WriteLine("Please specify the project full path as an argument");
                  return;
                  }

                  var projFile = args[0];
                  if (!File.Exists(projFile))
                  {
                  Console.WriteLine("The specified project file does not exist: {0}", projFile);
                  return;
                  }

                  if (!projFile.ToLowerInvariant().EndsWith(".csproj"))
                  {
                  Console.WriteLine("The specified does not seem to be a project file: {0}", projFile);
                  return;
                  }

                  Console.WriteLine("Started removing missing files from project:", projFile);

                  var newProjFile = Path.Combine(Path.GetDirectoryName(projFile), Path.GetFileNameWithoutExtension(projFile) + ".Clean.csproj");
                  var lines = File.ReadAllLines(projFile);
                  var projectPath = Path.GetDirectoryName(projFile);
                  for(var i = 0; i < lines.Length; i++)
                  {
                  var line = lines[i];
                  if (!line.Contains("<Content Include="") && !line.Contains("<None Include=""))
                  {
                  newFile.Add(line);
                  }
                  else
                  {
                  var start = line.IndexOf("Include="") + "Include="".Length;
                  var end = line.LastIndexOf(""");
                  var path = line.Substring(start, end - start);
                  if (File.Exists(Path.Combine(projectPath, path)))
                  {
                  newFile.Add(line);
                  }
                  else
                  {
                  if (!line.EndsWith("/>")) // I'm assuming it's only one line inside the tag
                  i += 2;
                  }
                  }
                  }
                  File.WriteAllLines(newProjFile, newFile);

                  Console.WriteLine("Finished removing missing files from project.");
                  Console.WriteLine("Cleaned project file: {0}", newProjFile);
                  }
                  }
                  }


                  https://github.com/woodp/remove-missing-project-files







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Dec 7 '17 at 0:39

























                  answered Dec 6 '17 at 19:52









                  PedroPedro

                  1,347611




                  1,347611






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f9166602%2fremove-vs2010-references-to-deleted-files-in-web-project%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Costa Masnaga

                      Fotorealismo

                      Sidney Franklin