Kinook Software Forum

Kinook Software Forum (https://www.kinook.com/Forum/index.php)
-   [VBP] Third Party Tools (https://www.kinook.com/Forum/forumdisplay.php?f=3)
-   -   Get Assembly version\OutputType from a csproj file (https://www.kinook.com/Forum/showthread.php?t=2964)

teognost 08-27-2007 01:27 PM

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:


Local
8.0.50727
2.0 AutoTrader.BICManagement
Library
pLocation>


..\..\..\bin\Debug\
false



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

1 Attachment(s)
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 :



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

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

1 Attachment(s)
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

1 Attachment(s)
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/vb...f_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 = 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.

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/d...1-27e85e1857b1

http://www.microsoft.com/downloads/d...B-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 ?


All times are GMT -5. The time now is 10:51 AM.


Copyright © 1999-2023 Kinook Software, Inc.