通过msbuild更改CSProject的AssemblyName

编程入门 行业动态 更新时间:2024-10-26 17:21:08
本文介绍了通过msbuild更改CSProject的AssemblyName的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个在编译时会调用*.sln文件的msbuild.此解决方案文件包含10个csproject,其中一个(称为main.csproject)具有AssemblyName作为WinMusic. msbuild的内容如下:

I have a msbuild that calls a *.sln file when doing compilation. This solution file contains 10 csprojects, one of them ( let's call it main.csproject) has the AssemblyName as WinMusic. The content of the msbuild is as follows:

<?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="schemas.microsoft/developer/msbuild/2003"> <PropertyGroup> <!-- Default value here --> <DefineConstants Condition=" '$(DefineConstants)'==''" >TRACE</DefineConstants> <SlnFiles Condition=" '$(SlnFiles)'==''" >FullProject.sln</SlnFiles> </PropertyGroup> <!-- <ItemGroup> --> <!-- <SlnFiles Include="SlnFiles=$(SlnFiles2)"/> --> <!-- </ItemGroup> --> <Target Name="Build"> <MSBuild Projects="$(SlnFiles)" Properties="DefineConstants=$(DefineConstants)"/> </Target> </Project>

我的问题是,如何从上述msbuild任务中设置AssemblyName属性?

My question is, how to set the AssemblyName property from the above msbuild task?

请澄清一下,我说的是csproject中的AssemblyName,而不是AssemblyInfo.cs中的.

Just to clarify, I'm talking about AssemblyName in csproject, not in AssemblyInfo.cs.

这是我尝试的新的build.proj文件,FullProject.sln是具有一个exe和一个dll的解决方案文件,但msbuild文件将dll和exe重命名为NoMusic.我想要的只是将exe重命名为NoMusic,而dll应该保留相同的名称.

This is the new build.proj file I tried, the FullProject.sln is a solution file with one exe and one dll, but the msbuild file renamed both the dll and the exe to NoMusic. What I want is just to rename the exe to NoMusic and the dll should retain the same name.

<?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="schemas.microsoft/developer/msbuild/2003"> <PropertyGroup> <!-- Default value here --> <DefineConstants Condition=" '$(DefineConstants)'==''" >TRACE</DefineConstants> <SlnFiles Condition=" '$(SlnFiles)'==''" >FullProject.sln</SlnFiles> </PropertyGroup> <Target Name="Build"> <MSBuild Projects="$(SlnFiles)" Properties="DefineConstants=$(DefineConstants)"/> <MSBuild Projects="WindowsFormsApplication1\WindowsFormsApplication1.csproj" Properties="DefineConstants=$(DefineConstants);Platform=ANYCPU;AssemblyName=NoMusic"/> </Target> </Project>

推荐答案

只需执行以下操作:

<Target Name="Build"> <MSBuild Projects="@(SlnFiles)" Properties="DefineConstants=$(DefineConstants)"/> <MSBuild Projects="main.csproject.csproj" Properties="AssemblyName=NoMusic"/>

喜欢知道为什么.

更多推荐

通过msbuild更改CSProject的AssemblyName

本文发布于:2023-11-13 14:13:39,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1584536.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:msbuild   CSProject   AssemblyName

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!