.NET Framework Bookmark and Share   
 index > MSBuild > Passing AssemblyInfo from a csproj to an MSBuild proj file.
 

Passing AssemblyInfo from a csproj to an MSBuild proj file.

How do I pass the value of a property from one project to another?
I have the following target defined within my project file:

Main.csproj:

<Target Name="AfterBuild">
<Message Text="AssemblyMajorVersion = $(AssemblyMajorVersion)"/>
<Message Text="AssemblyMinorVersion = $(AssemblyMinorVersion)"/>
<Message Text="MaxAssemblyVersion = $(MaxAssemblyVersion)"/>
<Message Text="MaxAssemblyFileVersion = $(MaxAssemblyFileVersion)"/>
<CreateProperty Value="$(MaxAssemblyVersion)">
<Output TaskParameter="Value" PropertyName="MaxAssemblyVersion" />
</CreateProperty>
</Target>

I have an MSBuild proj file that neds to use MaxAssemblyName in order to do a ClickOnce publish:


Publish.proj:

<?xml version="1.0" encoding="utf-8"?>
<Project InitialTargets="GetDefaults;SetDefaults;DoBuild;GetAssemblyVersion"
DefaultTargets="DoPublish"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003"
ToolsVersion="3.5">
<Target Name="DoBuild" >
<Message Text="Building occ600 in $(BuildMode) mode"/>
<Exec Command="CALL vsvars32.bat"
Condition="'$(DevEnvDir)' == ''"
WorkingDirectory="$(VS90COMNTOOLS)" />
<MSBuild Projects="..\..\Source\OCC600.sln" Targets="Clean;Build" Properties="Configuration=$(BuildMode)" />
<Message Text="Built occ600 version = $(MaxAssemblyVersion) in $(BuildMode) mode"/>
</Target>

<Target Name="DoPublish">

<Message Text="Publising occ600 Version $(MaxAssemblyVersion)"/>
<MSBuild Projects="..\..\Source\Infrastructure\Infrastructure.Shell\Infrastructure.Shell.csproj" Targets="Publish"
Properties="ApplicationVersion=$(MaxAssemblyVersion);Configuration=$(BuildMode);PublishDir=$(ClickOnceInstallDirectory)" />

</Target>
<Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/>
<Import Project="..\..\Source\Infrastructure\Infrastructure.Shell\Main.csproj"/>

</Project>

But when control returns to this target, MaxAssemblyVersion is always empty. How do I pass MaxAssemblyVersion from Main.csproj to Publish.proj?

TIA,

Klaus
knji
Never mind. Used Environment variables to pass data.
knji

You can use google to search for other answers

Custom Search

More Threads

• Updating Service References
• identifying build and rebuild Event
• A question about reference paths.
• Post-Build Events that used to work are not executed any more
• AssemblyInfoTask errors
• Help - toolsversion 2 removes code analysis rules
• String manipulation (how do I and/or improvement suggestion)
• Sdc.Tasks SetEnvironmentVariable - Why wont it set environment variables for me?
• Replace Visual Studio linker with (ICC12) alternate linker??
• problem with Build from command line usind devenev.exe