通过msbuild更改CSProject的AssemblyName [英] Change AssemblyName of a csproject via msbuild

查看:163
本文介绍了通过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="http://schemas.microsoft.com/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="http://schemas.microsoft.com/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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆