如何在 csproj 文件中添加目标内容?

发布于 2024-08-21 12:10:10 字数 1868 浏览 8 评论 0原文

我想根据配置向我的 Web 应用程序添加内容。我已经在缩写目标中声明了目标,目标如下所示:

  <Target Name="ApplicationNameDefinition" Outputs="$(MashupName)">
<MSBuild.ExtensionPack.Framework.TextString TaskAction="StartsWith" String1="$(ConfigurationName)" String2="Config1">
  <Output TaskParameter="Result" PropertyName="isConfig1" />
</MSBuild.ExtensionPack.Framework.TextString>
<MSBuild.ExtensionPack.Framework.TextString TaskAction="StartsWith" String1="$(ConfigurationName)" String2="Config2">
  <Output TaskParameter="Result" PropertyName="isConfig2" />
</MSBuild.ExtensionPack.Framework.TextString>
<MSBuild.ExtensionPack.Framework.TextString TaskAction="StartsWith" String1="$(ConfigurationName)" String2="Config3">
  <Output TaskParameter="Result" PropertyName="isConfig3" />
</MSBuild.ExtensionPack.Framework.TextString>
<MSBuild.ExtensionPack.Framework.TextString TaskAction="StartsWith" String1="$(ConfigurationName)" String2="Config4">
  <Output TaskParameter="Result" PropertyName="isConfig4" />
</MSBuild.ExtensionPack.Framework.TextString>
<Error Condition=" !$(isConfig1) And !$(isConfig2) And !$(isConfig3) And !$(isConfig4) " Text="Configuration $(ConfigurationName) Inconnue" />

<PropertyGroup>
  <MashupName Condition="$(isConfig1)">App1</MashupName>
  <MashupName Condition="$(isConfig2)">App2</MashupName>
  <MashupName Condition="$(isConfig3)">App3</MashupName>
  <MashupName Condition="$(isConfig4)">App4</MashupName>
</PropertyGroup>
<Error Condition="'$(MashupName)'==''" Text="Configuration $(MashupName) Inconnue" />
<ItemGroup >
  <Content Condition=" '$(MashupName)'!='' " Include="App_Themes\$(MashupName)\**" />
</ItemGroup>

但是,内容并未添加到项目中。有什么想法吗?

谢谢。

I would like to add content to my web application depending on the configuration. I have declared the target in the initials target and the target looks like this :

  <Target Name="ApplicationNameDefinition" Outputs="$(MashupName)">
<MSBuild.ExtensionPack.Framework.TextString TaskAction="StartsWith" String1="$(ConfigurationName)" String2="Config1">
  <Output TaskParameter="Result" PropertyName="isConfig1" />
</MSBuild.ExtensionPack.Framework.TextString>
<MSBuild.ExtensionPack.Framework.TextString TaskAction="StartsWith" String1="$(ConfigurationName)" String2="Config2">
  <Output TaskParameter="Result" PropertyName="isConfig2" />
</MSBuild.ExtensionPack.Framework.TextString>
<MSBuild.ExtensionPack.Framework.TextString TaskAction="StartsWith" String1="$(ConfigurationName)" String2="Config3">
  <Output TaskParameter="Result" PropertyName="isConfig3" />
</MSBuild.ExtensionPack.Framework.TextString>
<MSBuild.ExtensionPack.Framework.TextString TaskAction="StartsWith" String1="$(ConfigurationName)" String2="Config4">
  <Output TaskParameter="Result" PropertyName="isConfig4" />
</MSBuild.ExtensionPack.Framework.TextString>
<Error Condition=" !$(isConfig1) And !$(isConfig2) And !$(isConfig3) And !$(isConfig4) " Text="Configuration $(ConfigurationName) Inconnue" />

<PropertyGroup>
  <MashupName Condition="$(isConfig1)">App1</MashupName>
  <MashupName Condition="$(isConfig2)">App2</MashupName>
  <MashupName Condition="$(isConfig3)">App3</MashupName>
  <MashupName Condition="$(isConfig4)">App4</MashupName>
</PropertyGroup>
<Error Condition="'$(MashupName)'==''" Text="Configuration $(MashupName) Inconnue" />
<ItemGroup >
  <Content Condition=" '$(MashupName)'!='' " Include="App_Themes\$(MashupName)\**" />
</ItemGroup>

However, the content is not added to the project. Any Idea ?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

尾戒 2024-08-28 12:10:10

实际上,这在 msbuild 中有效,但在 Visual Studio 中无效,因为 Visual Studio 具有一些带有 csproj 文件的缓存...

Actually this works in msbuild, but not in Visual Studio which has some cache with csproj files...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文