Visual Studio “Add As Link” not working while debugging

前端 未结 4 1054
灰色年华
灰色年华 2020-12-24 02:28

I use Visual Studio 2010 to maintain around 40 different web applications that are all housed on the same website upon deployment. These projects are in the same solution b

4条回答
  •  伪装坚强ぢ
    2020-12-24 02:47

    The solution to this problem is copying content files (like js, css or others) which are added as link during each build. There are several ways to do this. I can advice to use MSBuild target which can be reused by different web application projects.

    So you can create the following file (for example by naming it WebApplication.Extension.targets) with the following content:

    
    
        
        
        
            
                CopyLinkedContentFiles;
                $(BuildDependsOn);
            
        
    
        
        
            
            
            
            
        
    
    

    And then add this target to you web application project by placing the following line in .csproj file:

    
    

    Basically you can add this line in .csproj file after the following one:

    
    

    After this problem with content files added as link should be resolved.

    Edit: To execute the following logic only when debug configuration is built in MSBUILD you have ability to specify Condition element.

    For example to import specified target only for debug configuration you can update import statement to the following:

    
    

    Edit2:

    To overcome this problem some time ago I created a 'MSBuild.WebApplication.CopyContentLinkedFiles' nuget package. This package adds MsBuild target which copies all content files added as link to project folder during build.

提交回复
热议问题