Kinook Software Forum

Go Back   Kinook Software Forum > Visual Build Professional > [VBP] Third Party Tools
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Rating: Thread Rating: 12 votes, 5.00 average. Display Modes
  #1  
Old 08-27-2007, 01:27 PM
teognost teognost is online now
Registered User
 
Join Date: 05-25-2004
Location: Prague,Czech Republic
Posts: 200
Get AssemblyName\OutputType from a csproj file

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?

Last edited by teognost; 08-28-2007 at 04:41 AM.
Reply With Quote
  #2  
Old 08-27-2007, 02:01 PM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,034
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.
Attached Files
File Type: zip csapp.zip (7.5 KB, 3621 views)
Reply With Quote
  #3  
Old 08-28-2007, 04:42 AM
teognost teognost is online now
Registered User
 
Join Date: 05-25-2004
Location: Prague,Czech Republic
Posts: 200
Sorry,my mistake,I mean AssemblyName instead of assembly version,i just corrected the title.Thanks for the sample...
Reply With Quote
  #4  
Old 09-07-2007, 01:44 PM
teognost teognost is online now
Registered User
 
Join Date: 05-25-2004
Location: Prague,Czech Republic
Posts: 200
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)VCProjectD efaults\UpgradeFromVC60.vsprops"
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...
Reply With Quote
  #5  
Old 09-07-2007, 03:23 PM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,034
The XML parser should handle either encoding properly. The attached sample worked in my tests.
Attached Files
File Type: zip outputfile.zip (1.9 KB, 3480 views)
Reply With Quote
  #6  
Old 09-10-2007, 12:53 PM
teognost teognost is online now
Registered User
 
Join Date: 05-25-2004
Location: Prague,Czech Republic
Posts: 200
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)%
Reply With Quote
  #7  
Old 09-10-2007, 01:24 PM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,034
The READ_XML macro doesn't support parameter values containing commas; use a Run Script action instead (see attached sample--requires VBP v6.5).
Attached Files
File Type: bld cpp_props2.bld (688 Bytes, 3442 views)
Reply With Quote
  #8  
Old 09-11-2007, 03:14 AM
teognost teognost is online now
Registered User
 
Join Date: 05-25-2004
Location: Prague,Czech Republic
Posts: 200
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
Reply With Quote
  #9  
Old 09-11-2007, 08:03 AM
teognost teognost is online now
Registered User
 
Join Date: 05-25-2004
Location: Prague,Czech Republic
Posts: 200
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?
Reply With Quote
  #10  
Old 09-11-2007, 08:26 AM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,034
If Not node Is Nothing Then ...

http://www.w3schools.com/vbscript/vb...f_keywords.asp
Reply With Quote
  #11  
Old 06-09-2008, 10:42 AM
teognost teognost is online now
Registered User
 
Join Date: 05-25-2004
Location: Prague,Czech Republic
Posts: 200
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?

Quote:
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.
Reply With Quote
  #12  
Old 06-09-2008, 01:53 PM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,034
Maybe it doesn't have a recent version of MSXML installed. Try installing the latest MSXML 6.0 release.

http://www.microsoft.com/downloads/d...1-27e85e1857b1

http://www.microsoft.com/downloads/d...B-3E9827B70604
Reply With Quote
  #13  
Old 06-10-2008, 04:47 AM
teognost teognost is online now
Registered User
 
Join Date: 05-25-2004
Location: Prague,Czech Republic
Posts: 200
tried both,it says I have a higher version already installed...
Reply With Quote
  #14  
Old 06-10-2008, 07:06 AM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,034
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.
Reply With Quote
  #15  
Old 06-10-2008, 11:22 AM
teognost teognost is online now
Registered User
 
Join Date: 05-25-2004
Location: Prague,Czech Republic
Posts: 200
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 ?
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



All times are GMT -5. The time now is 03:34 PM.


Copyright © 1999-2023 Kinook Software, Inc.