Comments (5)
Hi, thanks for the hint. What's your proposal now?
Some thoughts:
What caused the error to show up right now? Was anything changed by perforce, so this error can happen? Maybe the command line output which is used to find the entries by the search patterns: "User name:", "Client name:", "Client host:", "Client root:" ? Unfortunately I don't have access to perforce so I can't verify this.
from nantcontrib.
There might be several reasons for this. However, I suspect one of the properties is null in the context I'm running the p4 command.
Amending the code to the below would be the first thing I’d try.
protected override void ExecuteTask()
{
string[] find = {"User name:", "Client name:", "Client host:", "Client root:"};
string[] results = Perforce.GetP4Info(find);
if(results == null) throw new Exception(“Failed to retrieve P4 info.”);
Project.Properties[User] = results.Length > 0 ? results[0] : “unknown”;
Project.Properties[Client] = results.Length > 1 ? results[1] : “unknown”;
Project.Properties[Host] = results.Length > 2 ? results[2] : “unknown”;
Project.Properties[Root] = results.Length > 3 ? results[3] : “unknown”;
}
from nantcontrib.
Also, It might be useful to add a parameterized task GetP4Info for retrieving individual info fields.
from nantcontrib.
Hi,
hmm.... IMHO this length check won't help since GetP4Info
will always return a string array with length of find.Length
. In addition the result will not be null either.
Could you please show me your output of your p4 info
when you run it on your command line? As stated at p4 info docs the current implementation is still valid. Are you using a localized version?
from nantcontrib.
Assuming the “results” array is not null, not calling ToString() on each element would help in the sense it would retrieve the maximum information available instead of throwing a NullReferenceException. It's a good practice to implement validation in your code instead of relying on what thirdparty developers say. This issue itself shows why the best. That is the reason for additional checks to the length and results not being null. You never know in what context people may run it in the future.
I use standard version I believe.
Here’s the output my p4 info cmd line (I changed the environment specific values). It seems the Client Root is not there for some reason.
C:\Documents and Settings\user1>p4 info
User name: user1
Client name: currentbox
Client host: currentbox
Client unknown.
Current directory: c:\Documents and Settings\user1
Peer address: localIPAddress:clientport
Client address: localIPAddress
Server address: serverbox:serverport
Server root: /perforce/data
Server date: 2013/06/05 11:22:08 +0100 BST
Server uptime: 248:59:20
Server version: P4D/LINUX26X86_64/2012.2/538478 (2012/10/16)
Server license: licence details
Server license-ip: serverbox
Case Handling: insensitive
C:\Documents and Settings\user1>
from nantcontrib.
Related Issues (20)
- Import cvs task from NAnt
- Website updates
- reverse a string list HOT 4
- Add Ssh/Scp Tasks HOT 2
- Which codepage the code used? HOT 1
- NUnit2Report fails to render graphs on modern browsers HOT 1
- VSS task - using old interop dll HOT 7
- nunit2report counts ignored tests as "errors".
- waitforexit cannot capture failures HOT 4
- WaitForExitTask System.Security.SecurityException: Request failed HOT 2
- Cannot Compile On VS2012 HOT 1
- Consider Migrate to .NET 3.5+?
- iisapppool reports "Invalid namespace" HOT 1
- Add support for msbuild.exe v12.0 to the msbuild task HOT 3
- Registry path to vb6.exe incorrect for x64 HOT 1
- Mono build fails at MSI and SourceSafe tasks with mono 3.2.3++
- Amazing spell mistake.
- IIS web tasks do not support sites with secure bindings
- <link> task does not fail on unexisting library
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nantcontrib.