View Full Version : Get Assembly version\OutputType from a csproj file
teognost
08-27-2007, 01:27 PM
I need to get from a csproj file the assembly version and output type.
The file looks like this:
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectType>Local</ProjectType>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion> <AssemblyName>AutoTrader.BICManagement</AssemblyName>
<OutputType>Library</OutputType>
pLocation>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<OutputPath>..\..\..\bin\Debug\</OutputPath>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
</PropertyGroup>
</Project>
I tried to read it as an xml,having a 'Set Macro' step for CURRENT_ASSEMBLY_NAME:
%READ_XML(%CURRENT_FILE_LOCALFULLPATH%,Project/PropertyGroup/AssemblyName)%
but nothing is set...
However I noticed if the csproj doesn't contain the part
xmlns="http://schemas.microsoft.com/developer/msbuild/2003"-it is read correctly.
But this does not help me ,I need to read the csproj file as it is ,with
xmlns="http://schemas.microsoft.com/developer/msbuild/2003"
part inside.
Any idea how can I do it?
kinook
08-27-2007, 02:01 PM
The assembly version is stored in the AssemblyInfo.cs file and can be retrieved via the VS.NET Get Version action. The attached sample demonstrates that and retrieving the OutputType from the .csproj file.
teognost
08-28-2007, 04:42 AM
Sorry,my mistake,I mean AssemblyName instead of assembly version,i just corrected the title.Thanks for the sample...
teognost
09-07-2007, 01:44 PM
Now I have a similar issue when trying to retrieve OutputFile from a vcproj file,did not succed to get the info.
File looks like :
<?xml version="1.0" encoding="windows-1250"?>
<VisualStudioProject>
<Configurations>
<Configuration
Name="Unicode Release|Win32"
OutputDirectory=".\ReleaseU-vc80"
IntermediateDirectory=".\ReleaseU-vc80"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.v sprops"
UseOfMFC="0"
UseOfATL="2"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="1"
>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="odbc32.lib odbccp32.lib ws2_32.lib"
OutputFile="../../../bin/release-vc80\DebtGw.exe"
LinkIncremental="1"
SuppressStartupBanner="true"
AdditionalLibraryDirectories="..\..\..\LIB-vc80"
GenerateDebugInformation="true"
ProgramDatabaseFile="../../../bin/release-vc80\DebtGw.pdb"
GenerateMapFile="true"
MapFileName="../../../bin/release-vc80\DebtGw.map"
SubSystem="2"
TargetMachine="1"
/>
......
I need to extract the value written in
OutputFile="../../../bin/release-vc80\DebtGw.exe"
and problem is in some cases first line in vcproj file could look like
<?xml version="1.0" encoding="Windows-1252"?>
so I need a search method being able to extract the OutputFile no matter which of these 2 types first line would be...
kinook
09-07-2007, 03:23 PM
The XML parser should handle either encoding properly. The attached sample worked in my tests.
teognost
09-10-2007, 12:53 PM
Thanks,it works indeed .But if I want to search for the OutputFile written in first configuration containing word 'Release'-how can I do it?
Basically in your sample was:
%READ_XML(%XML_FILE%,/VisualStudioProject/Configurations/Configuration[@Name='Release|Win32']/Tool[@Name='VCLinkerTool']/@OutputFile)%
and I tried these 2 types of syntaxes but did not work;
%READ_XML(%XML_FILE%,/VisualStudioProject/Configurations/Configuration[contains(@Name,'Release')]/Tool[@Name='VCLinkerTool']/@OutputFile)%
%READ_XML(%XML_FILE%,/VisualStudioProject/Configurations/Configuration[@Name contains(.,'Release')]/Tool[@Name='VCLinkerTool']/@OutputFile)%
kinook
09-10-2007, 01:24 PM
The READ_XML macro doesn't support parameter values containing commas; use a Run Script action instead (see attached sample--requires VBP v6.5).
teognost
09-11-2007, 03:14 AM
Thanks,I adapted your script for VBP 6.3:
Set cof = vbld_AllMacros()("CURRENT_OUTPUT_FILE")
' load the XML file
Set msxml = CreateObject("MSXML2.DOMDocument.6.0")
msxml.async = False
msxml.load("%CURRENT_ASSOCIATED_INFOFILE_FULLPATH%")
Set node=msxml.selectSingleNode("/VisualStudioProject/Configurations/Configuration[contains(@Name, 'Release')]/Tool[@Name='VCLinkerTool']/@OutputFile")
cof.Value=node.Text
teognost
09-11-2007, 08:03 AM
Well,problem is the step fails when the xml file does not contain the related path.I need in such a case to set cof.Value to an empty string.
I tried to test the node object with IsNull,IsObject but the result is always positive,even if the object was not set due to not existent XPath.
So how can be tested the node object in order to avoid the step failure?
kinook
09-11-2007, 08:26 AM
If Not node Is Nothing Then ...
http://www.w3schools.com/vbscript/vbscript_ref_keywords.asp
teognost
06-09-2008, 10:42 AM
Hi,I am trying to execute the sample you attached (csapp.zip) on another box where OS is Win2003 (my box has WinXp installed).
Problem is in this case the step 'Log properties' fails:
Error expanding macros or script in property Message: Output type = <Error expanding macro value: Reference to undeclared namespace prefix: 'msbuild'.
Any idea why?
Originally posted by kinook
The assembly version is stored in the AssemblyInfo.cs file and can be retrieved via the VS.NET Get Version action. The attached sample demonstrates that and retrieving the OutputType from the .csproj file.
kinook
06-09-2008, 01:53 PM
Maybe it doesn't have a recent version of MSXML installed. Try installing the latest MSXML 6.0 release.
http://www.microsoft.com/downloads/details.aspx?FamilyID=993c0bcf-3bcf-4009-be21-27e85e1857b1
http://www.microsoft.com/downloads/details.aspx?FamilyID=D21C292C-368B-4CE1-9DAB-3E9827B70604
teognost
06-10-2008, 04:47 AM
tried both,it says I have a higher version already installed...
kinook
06-10-2008, 07:06 AM
I'm not sure then. I tried it on Windows 2003 SP2 before and after installing MSXML 6.0 and 6.0 SP1, and it worked in all cases.
teognost
06-10-2008, 11:22 AM
I tried again and again to understand what is wrong on that box-still no clue :-(
In the step:
Output type = %READ_XML(%XML_FILE%,/msbuild:Project/msbuild:PropertyGroup/msbuild:OutputType, ,xmlns:msbuild='http://schemas.microsoft.com/developer/msbuild/2003')%
what represents msbuild ?
kinook
06-10-2008, 01:26 PM
The alias for the http://schemas.microsoft.com/developer/msbuild/2003 namespace.
teognost
06-11-2008, 04:40 AM
Well,finally I solved it.
I noticed on my box I have VBP 6.7 and on W2003 is VBP 6.2,installed 6.7 and it is ok now!!
vBulletin® v3.8.11, Copyright ©2000-2024, vBulletin Solutions Inc.