#1
|
|||
|
|||
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. |
#2
|
|||
|
|||
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.
|
#3
|
|||
|
|||
Sorry,my mistake,I mean AssemblyName instead of assembly version,i just corrected the title.Thanks for the sample...
|
#4
|
|||
|
|||
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... |
#5
|
|||
|
|||
The XML parser should handle either encoding properly. The attached sample worked in my tests.
|
#6
|
|||
|
|||
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)% |
#7
|
|||
|
|||
The READ_XML macro doesn't support parameter values containing commas; use a Run Script action instead (see attached sample--requires VBP v6.5).
|
#8
|
|||
|
|||
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 |
#9
|
|||
|
|||
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? |
#10
|
|||
|
|||
#11
|
|||
|
|||
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:
|
#12
|
|||
|
|||
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 |
#13
|
|||
|
|||
tried both,it says I have a higher version already installed...
|
#14
|
|||
|
|||
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.
|
#15
|
|||
|
|||
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 ? |
|
|