Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -68,44 +68,45 @@ public bool TryGetUsedPackagesDependendingOnNugetOutput(out ITaskItem[] packages
using (var archive = Package.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read))
{
var nuspec = archive.GetParts().Single(part => part.Uri.ToString().EndsWith(".nuspec"));
var nugetSpec = Path.Combine(nupkgpath, Path.GetFileName(nuspec.Uri.ToString()));
var nuspecFilename = Path.GetFileName(nuspec.Uri.ToString());
var nugetSpec = Path.Combine(nupkgpath, nuspecFilename);

// use a mutex to ensure that only one process unzip the nuspec
// and that one process do not start reading it due to its existence while another one is still writing it.
if (!File.Exists(nugetSpec))
var mut = new Mutex(false, nuspecFilename);
var xml = new XmlDocument();
try
{
var mut = new Mutex(false, "UnzipNuSpec");
try
{
mut.WaitOne();
mut.WaitOne();

if (!File.Exists(nugetSpec))
try
if (!File.Exists(nugetSpec))
{
try
{
using (
var outputstream = new FileStream(nugetSpec, FileMode.Create,
FileAccess.ReadWrite, FileShare.None))
{
using (
var outputstream = new FileStream(nugetSpec, FileMode.Create,
FileAccess.ReadWrite, FileShare.None))
using (var nspecstream = nuspec.GetStream())
{
using (var nspecstream = nuspec.GetStream())
{
nspecstream.CopyTo(outputstream);
}
nspecstream.CopyTo(outputstream);
}
}
catch (IOException)
{
if (!File.Exists(nugetSpec))
throw;
}
}
finally
{
mut.ReleaseMutex();
}
catch (IOException)
{
if (!File.Exists(nugetSpec))
throw;
}
}
}

var xml = new XmlDocument();
xml.LoadXml(File.ReadAllText(nugetSpec));
xml.Load(nugetSpec);
}
finally
{
mut.ReleaseMutex();
}

var deps = xml.GetElementsByTagName("dependency");
foreach (XmlNode dep in deps)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
<projectUrl>http://www.baseclass.ch/Contrib/Nuget</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Treats the "output" folder in an dependend nuget package as an additional special folder and copies it's content to the build folder</description>
<releaseNotes xml:space="preserve">- Added support for paket
- Added support for repository path configuration</releaseNotes>
<releaseNotes xml:space="preserve">- Fix concurrency issue regression
- Reduce scope of the mutex to optimize parallel compilations</releaseNotes>
<tags>Nuget Targets Copy Output build package convention</tags>
</metadata>
<files>
Expand Down