我在我的视觉工作室解决方案中设置了一个项目, 包含许多链接的文件。 这些是内容文件 。
当我建造这个项目时,我想把链接的文件复制到另一个地方。这有可能吗? 我怎样才能做到这一点?
我在我的视觉工作室解决方案中设置了一个项目, 包含许多链接的文件。 这些是内容文件 。
当我建造这个项目时,我想把链接的文件复制到另一个地方。这有可能吗? 我怎样才能做到这一点?
For anybody stumbling on this page like myself, further to 5arx post, I implemented an MSBuild target that copies all linked content files to their "virtual" locations (the directory where you placed the link in Visual Studio): http://mattperdeck.com/post/Copying-linked-content-files-at-each-build-using-MSBuild.aspx
多年来,我一直使用,但用视觉工作室2022/.NET 6,它根本行不通。视觉工作室似乎不再“看到”任何作为链接添加的内容文件,而副本基本上什么都不用。
下面是我现在的工作。在我的例子中,我有一大堆联署材料, 包含在wwwroot/common/js的多个项目中。 我在我的 CSPROJ 档案中添加以下内容:
<ItemGroup>
<!-- Adds the files as links in the Solution Explorer.
When you double-click, it opens the original file. -->
<Content Include="....Common***.js">
<Link>wwwrootCommon\%(RecursiveDir)%(FileName)%(Extension)</Link>
</Content>
<!-- Picked up by the Copy below. Using "Content"
with "Link" adds external files as links. But a custom
name is needed for use with Copy. -->
<CommonJs Include="....Common***.js" />
<!-- Tells Visual Studio to ignore any actual files at this location.
I found that if I didn t do this, Visual Studio sees the copied
file instead of the linked file. This tells Visual Studio to
ignore the copied file so that when I double-click it in
Solution Explorer, it opens the original copy. -->
<Content Remove="wwwrootCommon**" />
</ItemGroup>
<Target Name="CopyCommonJs" BeforeTargets="Build">
<Copy SourceFiles="@(CommonJs)"
DestinationFiles="wwwrootCommon\%(RecursiveDir)%(Filename)%(Extension)"
SkipUnchangedFiles="true"
OverwriteReadOnlyFiles="true" />
</Target>
整个方法行之有效,我现在理解了所有部分,但我更喜欢旧的方法,希望它仍然有效。 如果有人找到更优雅的东西,请告诉我。
如果您右键单击工程, 请选择“ 构建事件” 选项卡, 您应该能够创建一个创建日志的事件脚本, 该脚本将包含您指定的任何文件, 并复制到您指定的位置 。
良好的起点是 < a href=>""http://msdn.microsoft.com/en-us/library/ke5z92ks.aspx" rel="no follow" >这里
您可以使用“ http://msdn.microsoft.com/ en- us/library/ 0k6kkbsd” rel = “ no follow” >MSBruild 。 具体来说, 其< a href=> http://msdn. microsoft. com/ en- us/library/3e54c37h.aspx" rel=“ nofolpol” > Copy 文件 任务 :
似乎只是简单地添加:
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
与视觉工作室 2017 csproj 工程文件中的链接文件项相关联, 将使链接文件被复制到建设中的输出目录, 不论您是否宣布构建动作为无或内容 。
举例来说,这两个工作...
<None Include="..configurationShared.OctopusDeploy.config">
<Link>Shared.OctopusDeploy.config</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<Content Include="..configurationShared.OctopusDeploy.config">
<Link>Shared.OctopusDeploy.config</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
In my webpages I have references to js and images as such: "../../Content/Images/"Filename" In my code if I reference a file as above, it doesnt work so i have to write: "c:/miscfiles/"filename" 1-...
I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...
Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...
I m looking for best practices here. Sorry. I know it s subjective, but there are a lot of smart people here, so there ought to be some "very good" ways of doing this. I have a custom object called ...
I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...
i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...
For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?
I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!