asp.net – Visual Studio“添加为链接”调试时不工作
我使用Visual Studio 2010来维护大约40个不同的web应用程序,它们都部署在同一个网站上。这些项目在同一个解决方案中,但是它们位于不同的项目中,因为它们各有不同。
我正在尝试通过“添加为链接”选项在各种项目之间共享css / js文件,以便我可以更新css或js文件一次,并自动将更新反映在各种项目中,而无需构建和重新部署每个项目。 我遇到的问题是当我试图在我的电脑上在本地运行一个项目以进行调试时,这些链接的文件不起作用。我正在找到一个没有找到的文件。
谢谢, 解决方法
解决这个问题的办法是复制每个构建期间作为链接添加的内容文件(如js,css或其他)。有几种方法可以做到这一点。我可以建议使用可以由不同的Web应用程序项目重用的MSBuild目标。
因此,您可以使用以下内容创建以下文件(例如,将其命名为WebApplication.Extension.targets): <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <!-- Override the default target dependencies to --> <!-- include the new CopyLinkedContentFiles target. --> <PropertyGroup> <BuildDependsOn> CopyLinkedContentFiles; $(BuildDependsOn); </BuildDependsOn> </PropertyGroup> <!-- ============================================================ CopyLinkedContentFiles A new target to copy any linked content files into the web application output folder. NOTE: This is necessary even when '$(OutDir)' has not been redirected. ============================================================ --> <Target Name="CopyLinkedContentFiles"> <!-- Remove any old copies of the files --> <Delete Condition=" '%(Content.Link)' != '' AND Exists('$(WebProjectOutputDir)%(Content.Link)') " Files="$(WebProjectOutputDir)%(Content.Link)" /> <!-- Copy linked content files recursively to the project folder --> <Copy Condition=" '%(Content.Link)' != '' " SourceFiles="%(Content.Identity)" DestinationFiles="$(WebProjectOutputDir)%(Content.Link)" /> </Target> </Project> 然后通过在.csproj文件中放置以下行将此目标添加到Web应用程序项目中: <Import Project="$(MSBuildProjectDirectory)[RelativePathToFile]WebApplication.Extension.targets" /> 基本上你可以在.csproj文件中添加以下行: <Import Project="$(MSBuildBinPath)Microsoft.CSharp.targets" /> 此问题后,内容文件添加为链接应该被解决。 编辑: 例如,只有为调试配置导入指定的目标,您可以将import语句更新为以下内容: <Import Project="$(MSBuildProjectDirectory)[RelativePathToFile]WebApplication.Extension.targets" Condition=" '$(Configuration)' == 'Debug' "/> 编辑2: 为了克服这个问题,前段时间我创建了一个’MSBuild.WebApplication.CopyContentLinkedFiles‘nuget包。此程序包添加MsBuild目标,该目标在构建过程中将所有添加到链接的内容文件复制到项目文件夹。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- asp.net-mvc – 模型绑定到MVC 3中可能存在非顺序索引的列表
- ASP.NET MVC 5 – RazorGenerator与发布期间的发布预编译
- ASP.NET MVC:访问日志
- asp.net-mvc – 可在LAN中远程访问的IIS页面,但不能在服务器
- asp.net – 有什么功能,将帮助我重构CSS
- 项目中出现多个域名下的Cookie
- asp.net-mvc – 在ASP.NET MVC视图中使用代码隐藏
- asp.net-mvc – 可以将NUnit集成到Visual Studio 2010中吗?
- asp.net-mvc – AddImplicitRequiredAttributeForValueType
- 提供第三种代码生成方式——通过自定义BuildProvider为ASP.
- ABP官方文档(八)【会话管理】
- ABP官方文档(三十二)【MVC Controllers】
- asp.net – GridView中的TemplateField标题
- asp.net-mvc – 多租户Razor页面
- asp.net-mvc – 在使用ORM解决方案的ASP.NET MVC
- asp.net-mvc-4 – 使用ELMAH和ajax在ASP.Net MVC
- 用asp.net MVC局部视图加载jquery
- asp.net – 对齐和填充为asp:CheckBoxList
- ASP.NET System.Data.EntityClient连接字符串帮助
- asp.net – 如何在IIS中部署.NET Web项目