Edited code to fix this issue: http://npanday.codeplex.com/WorkItem/View.aspx?WorkItemId=10372
git-svn-id: https://svn.apache.org/repos/asf/incubator/npanday/trunk@994066 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/assemblies/NPanday.Artifact/src/main/csharp/NPanday/Artifact/ArtifactRepository.cs b/assemblies/NPanday.Artifact/src/main/csharp/NPanday/Artifact/ArtifactRepository.cs
index 7370052..e038287 100644
--- a/assemblies/NPanday.Artifact/src/main/csharp/NPanday/Artifact/ArtifactRepository.cs
+++ b/assemblies/NPanday.Artifact/src/main/csharp/NPanday/Artifact/ArtifactRepository.cs
@@ -1,35 +1,35 @@
-#region Apache License, Version 2.0
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-#endregion
-
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Text;
-using System.Xml;
-using System.Xml.Serialization;
-using System.Windows.Forms;
-
-namespace NPanday.Artifact
-{
- public sealed class ArtifactRepository
+#region Apache License, Version 2.0
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Text;
+using System.Xml;
+using System.Xml.Serialization;
+using System.Windows.Forms;
+
+namespace NPanday.Artifact
+{
+ public sealed class ArtifactRepository
{
public string GetLocalUacPath(Artifact artifact, string ext)
@@ -39,79 +39,96 @@
public string GetLocalRepositoryPath(Artifact artifact, string ext)
{
- return Path.Combine(localRepository.FullName, string.Format(@"repository\{0}\{1}\{2}\{1}-{2}{3}", artifact.GroupId, artifact.ArtifactId, artifact.Version,ext));
+ return Path.Combine(localRepository.FullName, string.Format(@"repository\{0}\{1}\{2}\{1}-{2}{3}", artifact.GroupId, artifact.ArtifactId, artifact.Version,ext));
}
public string GetRemoteRepositoryPath(Artifact artifact, string url, string ext)
{
- return string.Format("{0}/{1}/{2}/{3}/{2}-{3}{4}", url, artifact.GroupId, artifact.ArtifactId, artifact.Version, ext);
- }
-
- public Artifact GetArtifactFor(String uri)
- {
- DirectoryInfo uac = new DirectoryInfo(localRepository.FullName + @"\uac\gac_msil\");
-
- String[] tokens = uri.Split("/".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
- int size = tokens.Length;
- if (size < 3)
- {
- throw new IOException("Invalid Artifact Path = " + uri);
- }
- Artifact artifact = new Artifact();
- artifact.ArtifactId = tokens[size - 3];
- StringBuilder buffer = new StringBuilder();
- for (int i = 0; i < size - 3; i++)
- {
- buffer.Append(tokens[i]);
- if (i != size - 4)
- {
- buffer.Append(".");
- }
- }
- artifact.GroupId = buffer.ToString();
- artifact.Version = tokens[size - 2];
- artifact.Extension = tokens[size - 1].Split(".".ToCharArray())[1];
- artifact.FileInfo = new FileInfo(uac.FullName + artifact.ArtifactId + @"\" +
- artifact.Version + "__" + artifact.GroupId + @"\" + artifact.ArtifactId + ".dll" );
- return artifact;
- }
-
- public List<Artifact> GetArtifacts()
- {
- List<Artifact> artifacts = new List<Artifact>();
- try
- {
- DirectoryInfo uac = new DirectoryInfo(localRepository.FullName + @"\uac\gac_msil\");
- int directoryStartPosition = uac.FullName.Length;
-
- List<FileInfo> fileInfos = GetArtifactsFromDirectory(uac);
-
- foreach (FileInfo fileInfo in fileInfos)
- {
- try
- {
- Artifact artifact = GetArtifact(uac, fileInfo);
- artifacts.Add(artifact);
- }
- catch
- {
-
- }
- }
- }
- catch (Exception e)
- {
- MessageBox.Show(e.StackTrace, e.Message);
- }
- return artifacts;
- }
-
- #region Repository Artifact Info Helper
-
- public Artifact GetArtifact(FileInfo artifactFile)
- {
- DirectoryInfo uacDirectory = new DirectoryInfo(localRepository.FullName + @"\uac\gac_msil\");
- return GetArtifact(uacDirectory, artifactFile);
+ return string.Format("{0}/{1}/{2}/{3}/{2}-{3}{4}", url, artifact.GroupId, artifact.ArtifactId, artifact.Version, ext);
+ }
+
+ public Artifact GetArtifactFor(String uri)
+ {
+ Artifact artifact = new Artifact();
+
+ DirectoryInfo uac = new DirectoryInfo(localRepository.FullName + @"\uac\gac_msil\");
+
+ String[] tokens = uri.Split("/".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
+ int size = tokens.Length;
+ if (size < 3)
+ {
+ System.Reflection.Assembly a = System.Reflection.Assembly.LoadFile(uri);
+ string[] info = a.FullName.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
+ artifact.ArtifactId = info[0];
+ artifact.GroupId = info[0];
+ artifact.Version = info[1].Split(new char[] { '='})[1];
+ artifact.Extension = tokens[0].Split(new char[] { '.' })[1];
+
+ if (artifact.Version == null)
+ {
+ artifact.Version = "1.0.0.0";
+ }
+ }
+
+ else
+ {
+ artifact.ArtifactId = tokens[size - 3];
+ StringBuilder buffer = new StringBuilder();
+ for (int i = 0; i < size - 3; i++)
+ {
+ buffer.Append(tokens[i]);
+ if (i != size - 4)
+ {
+ buffer.Append(".");
+ }
+ }
+ artifact.GroupId = buffer.ToString();
+ artifact.Version = tokens[size - 2];
+ String[] extToken = tokens[size - 1].Split(".".ToCharArray());
+ artifact.Extension = extToken[extToken.Length - 1];
+ }
+
+ artifact.FileInfo = new FileInfo(uac.FullName + artifact.ArtifactId + @"\" +
+ artifact.Version + "__" + artifact.GroupId + @"\" + artifact.ArtifactId + ".dll");
+ return artifact;
+ }
+
+ public List<Artifact> GetArtifacts()
+ {
+ List<Artifact> artifacts = new List<Artifact>();
+ try
+ {
+ DirectoryInfo uac = new DirectoryInfo(localRepository.FullName + @"\uac\gac_msil\");
+ int directoryStartPosition = uac.FullName.Length;
+
+ List<FileInfo> fileInfos = GetArtifactsFromDirectory(uac);
+
+ foreach (FileInfo fileInfo in fileInfos)
+ {
+ try
+ {
+ Artifact artifact = GetArtifact(uac, fileInfo);
+ artifacts.Add(artifact);
+ }
+ catch
+ {
+
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ MessageBox.Show(e.StackTrace, e.Message);
+ }
+ return artifacts;
+ }
+
+ #region Repository Artifact Info Helper
+
+ public Artifact GetArtifact(FileInfo artifactFile)
+ {
+ DirectoryInfo uacDirectory = new DirectoryInfo(localRepository.FullName + @"\uac\gac_msil\");
+ return GetArtifact(uacDirectory, artifactFile);
}
public Artifact GetArtifact(NPanday.Model.Pom.Dependency dependency)
@@ -121,11 +138,11 @@
artifact.GroupId = dependency.groupId;
artifact.Version = dependency.version;
artifact.FileInfo = new FileInfo( GetLocalRepositoryPath(artifact, ".dll"));
- return artifact;
- }
-
- public Artifact GetArtifact(DirectoryInfo uacDirectory, FileInfo artifactFile)
- {
+ return artifact;
+ }
+
+ public Artifact GetArtifact(DirectoryInfo uacDirectory, FileInfo artifactFile)
+ {
string[] tokens;
try
{
@@ -160,13 +177,13 @@
artifact.Version = version;
artifact.GroupId = groupId;
artifact.FileInfo = new FileInfo(GetLocalUacPath(artifact, ext));
- return artifact;
- }
-
-
-
- string getVersion(string versionAndGroupDirectoryName)
- {
+ return artifact;
+ }
+
+
+
+ string getVersion(string versionAndGroupDirectoryName)
+ {
try
{
// 1.1.1.1__NMaven.VisualStudio from index 0 to __ is the version number
@@ -177,11 +194,11 @@
catch
{
return string.Empty;
- }
- }
-
- string getGroupId(string versionAndGroupDirectoryName)
- {
+ }
+ }
+
+ string getGroupId(string versionAndGroupDirectoryName)
+ {
try
{
int index = versionAndGroupDirectoryName.IndexOf("__", 0) + 2;
@@ -192,38 +209,38 @@
catch
{
return string.Empty;
- }
- }
-
- #endregion
-
-
-
- public void Init(ArtifactContext artifactContext, DirectoryInfo localRepository)
- {
- this.artifactContext = artifactContext;
- this.localRepository = localRepository;
- }
-
- private List<FileInfo> GetArtifactsFromDirectory(DirectoryInfo baseDirectoryInfo)
- {
- DirectoryInfo[] directories = baseDirectoryInfo.GetDirectories();
- List<FileInfo> fileInfos = new List<FileInfo>();
- foreach (DirectoryInfo directoryInfo in directories)
- {
- foreach (FileInfo fileInfo in directoryInfo.GetFiles())
- {
- if (fileInfo.Name.EndsWith(".dll") || fileInfo.Name.EndsWith(".exe") || fileInfo.Name.EndsWith(".netmodule") )
- {
- fileInfos.Add(fileInfo);
- }
- }
- fileInfos.AddRange(GetArtifactsFromDirectory(directoryInfo));
- }
- return fileInfos;
- }
-
- private ArtifactContext artifactContext;
- private DirectoryInfo localRepository;
- }
-}
+ }
+ }
+
+ #endregion
+
+
+
+ public void Init(ArtifactContext artifactContext, DirectoryInfo localRepository)
+ {
+ this.artifactContext = artifactContext;
+ this.localRepository = localRepository;
+ }
+
+ private List<FileInfo> GetArtifactsFromDirectory(DirectoryInfo baseDirectoryInfo)
+ {
+ DirectoryInfo[] directories = baseDirectoryInfo.GetDirectories();
+ List<FileInfo> fileInfos = new List<FileInfo>();
+ foreach (DirectoryInfo directoryInfo in directories)
+ {
+ foreach (FileInfo fileInfo in directoryInfo.GetFiles())
+ {
+ if (fileInfo.Name.EndsWith(".dll") || fileInfo.Name.EndsWith(".exe") || fileInfo.Name.EndsWith(".netmodule") )
+ {
+ fileInfos.Add(fileInfo);
+ }
+ }
+ fileInfos.AddRange(GetArtifactsFromDirectory(directoryInfo));
+ }
+ return fileInfos;
+ }
+
+ private ArtifactContext artifactContext;
+ private DirectoryInfo localRepository;
+ }
+}
diff --git a/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/NPanday/VisualStudio/Addin/AddArtifactsForm.cs b/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/NPanday/VisualStudio/Addin/AddArtifactsForm.cs
index c083701..b5408ba 100644
--- a/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/NPanday/VisualStudio/Addin/AddArtifactsForm.cs
+++ b/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/NPanday/VisualStudio/Addin/AddArtifactsForm.cs
@@ -56,6 +56,7 @@
private FileInfo pom;
private WebClient webClient = new WebClient();
bool _remoteRepoChanged = false;
+ public bool fileProtocol = false;
@@ -681,8 +682,9 @@
String repoUrl = getRepositoryUrl();
if (node.IsFileSystem)
{
- Uri repoUri = new Uri(repoUrl);
- paths = uri.Substring(repoUri.LocalPath.Length).Replace(@"\",@"/");
+ //Uri repoUri = new Uri(repoUrl);
+ //paths = uri.Substring(repoUri.LocalPath.Length).Replace(@"\",@"/");
+ paths = uri;
}
else
{