2011-08-09 2 views
0

コンパイル時に*.slnファイルを呼び出すmsbuildがあります。このソリューションファイルには10個のcsprojectが含まれており、そのうちの1つ(main.csprojectと呼ぶ)のAssemblyNameWinMusicです。次のようにMSBuildのの内容は次のとおりです。msbuildを使用してcsprojectのAssemblyNameを変更します。

<?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プロパティを設定する方法、ありますか?

明確にするために、私はAssemblyInfo.csではなく、csprojectでAssemblyNameを話しています。

編集:これは私が試した新しいbuild.projファイルであり、FullProject.slnは1つのexeファイルと1つのDLLでのソリューションファイルですが、MSBuildのファイルがNoMusicへのdllとexeファイルの両方の名前を変更しました。私が望むのは、exeファイルの名前をNoMusicに変更するだけで、dllは同じ名前を保持する必要があります。

<?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> 

答えて

2

ちょうどこの操作を行います。しかし、なぜ知っている

<Target Name="Build"> 
    <MSBuild Projects="@(SlnFiles)" 
      Properties="DefineConstants=$(DefineConstants)"/> 

    <MSBuild Projects="main.csproject.csproj" 
     Properties="AssemblyName=NoMusic"/> 

愛を。

+0

この方法では、プロジェクトのプロパティを 'msbuild.exe main.csproject.csproj/p:AssemblyName = NoMusic'と同様に再定義します。 '/ p'スイッチが何をしているのかわからない場合はMSBuildのドキュメントを見てください。 –

+1

[こちら](http://social.msdn.microsoft.com/Forums/en/msbuild/thread/95a04398-05c1-4fea-b596-abbe156e6a84)は、MSBuildのプロパティ評価プロセスに関する広範な情報です。 –

+4

@James、私はそれが動作するとは思わない;ソリューション内に2つのプロジェクト(1つのexe、別のdll)がある場合、dllとexeの両方がNoMusicに名前変更されます。これは明らかに私が望むものではありません。 – Graviton

関連する問題