我有一个在编译时会调用*.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
发布评论