Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Baseclass.Contrib.Nuget.Output 2.3.0 fails on msbuild package #34

Closed
patrikholmberg opened this issue Apr 7, 2017 · 7 comments
Closed

Comments

@patrikholmberg
Copy link

Hi,

I'm having an issue that when trying to package my project for deploy, like msbuild myproject.csproj /T:package /P:Configuration=Debug.
An error ocurre in the Baseclass.Contrib.Nuget.Output.targets file with the error:

The "PackageRetrievalTask" task failed unexpectedly.
System.ArgumentException: Illegal characters in path.
   at System.Security.Permissions.FileIOPermission.EmulateFileIOPermissionChecks(String fullPath)
   at System.Security.Permissions.FileIOPermission.QuickDemand(FileIOPermissionAccess access, String[] fullPathList, Boolean checkForDuplicates, Boolean needFullPath)
   at System.IO.FileSystemEnumerableIterator`1..ctor(String path, String originalUserPath, String searchPattern, SearchOption searchOption, SearchResultHandler`1 resultHandler, Boolean checkHost)
   at System.IO.Directory.EnumerateFiles(String path, String searchPattern, SearchOption searchOption)
   at Baseclass.Contrib.Nuget.Output.Build.PackageRetrievalTask.GetFilteredProjectNugetPackages(NugetPackageSource currentNugetPackageSource, HashSet`1 usedNugetPackages)
   at Baseclass.Contrib.Nuget.Output.Build.PackageRetrievalTask.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()

The thing is, if I downgrade to 2.1.0 it works. But then VS2017 issue.

@cweb187
Copy link

cweb187 commented Apr 14, 2017

I get this same issue. I've worked around it, the Baseclass.Contrib.Nuget.Output.2.2.0-xbuild02 (was prerelease) version on nuget doesn't have this issue but also resolves the VS2017 error MSB4175: The task factory "CodeTaskFactory" could not be loaded from the assembly issue we had on 2.1.0.

@romerod
Copy link
Member

romerod commented Apr 15, 2017

Thanks for the comments, could you add some additional information:

  • csproj with PackageReference or packages.config
  • csproj path
  • solution path
  • Did you relocate the packages folder?

@patrikholmberg
Copy link
Author

Package is installed using nuget, so packages.config.
The path to the csproj contains no special character except for dash - and dots .

Solution path is outside of csproj folder like:
C:\my-dev-folder\solution\mysolution.sln
And
C:\my-dev-folder\solution\my.project\my.project.csproj

The package folder is in the root of the solution folder like C:\my-dev-folder\solution\packages\ and hasn't been relocated.

@mqtwinter
Copy link

I am getting this issue as well and I think I have a good idea why.

My setup:
This is a solution that contains (amongst other things) a web application project. That web application project depends on another project in the solution, which uses the nuget package libsodium-net. It depends on Baseclass.Contrib.Nuget.Output 2.1.0. The project using libsodium-net has a packages.config file in the same folder as its csproj file. The actual packages themselves are stored above the project folders at the solution level.

In order to compile with Visual Studio 2017 I upgraded to Baseclass.Contrib.Nuget.Output 2.3.0. Now things build OK in Visual Studio but it fails in my automated build. My automated build does a web deploy like this:

<MSBuild
				Projects="$(SourcePath)\Folder\MyProjectName.csproj"
				Properties="
					DeployOnBuild=true;
					DeployTarget=WebPublish;
					WebPublishMethod=FileSystem;
					PublishProfile=$(SomePath)\PublishProfile.pubxml;
					OutputPath=$(SomePath)\WebApplication.Temp;
					publishUrl=$(SomePath)\WebApplication;
					VisualStudioVersion=$(MSBuildToolsVersion);
					Configuration=$(Configuration);
					Platform=$(Platform);"
        ToolsVersion="$(MSBuildToolsVersion)"
		/>

Note how I am deploying a specific project, not the solution. "Projects" points to a .csproj file, not a .sln file. This appears to be what @gralov is doing also.

Turning on diagnostic logging in MsBuild shows that the SolutionDir property is undefined within this MsBuild, I assume because I'm not deploying a solution file. Below is the log file portion for CollectNugetOutputFiles which is what is failing. Note SolutionPath=Undefined. In PackageRetrievalTask that's the SolutionPath property. It's accessed in GetFilteredProjectNugetPackages() when the package source is PackagesConfig. I guess it's trying to get to the actual package that I have stored at the solution level. But since no solution path was passed in, it cannot find it. Kind of makes sense. I'm not sure there's anything you can do about this. I'll try fiddling with my msbuild call to get the solution path passed in.

MsBuild Diagnostic Log:

Target "CollectNugetOutputFiles" in file "C:\SomePath\packages\Baseclass.Contrib.Nuget.Output.2.3.0\build\net40\Baseclass.Contrib.Nuget.Output.targets":
  Task "Message"
    Task Parameter:Text=Collecting NuGet output files for DataArk.Infrastructure.Passwords:
    Collecting NuGet output files for DataArk.Infrastructure.Passwords:
  Done executing task "Message".
  Using "PackageRetrievalTask" task from assembly "C:\SomePath\packages\Baseclass.Contrib.Nuget.Output.2.3.0\build\net40\\Baseclass.Contrib.Nuget.Output.Build.dll".
  Task "PackageRetrievalTask"
    Task Parameter:ProjectName=MyProjectName
    Task Parameter:ProjectDirectory=C:\SomePath\Source\MyProjectName
    Task Parameter:ProjectFullPath=C:\SomePath\Source\MyProjectName\MyProjectName.csproj
    Task Parameter:SolutionPath=*Undefined*
    Reading config: C:\SomePath\Source\MyProjectName\packages.config
    C:\SomePath\packages\Baseclass.Contrib.Nuget.Output.2.3.0\build\net40\Baseclass.Contrib.Nuget.Output.targets(65,5): error MSB4018: The "PackageRetrievalTask" task failed unexpectedly.\r
    C:\SomePath\packages\Baseclass.Contrib.Nuget.Output.2.3.0\build\net40\Baseclass.Contrib.Nuget.Output.targets(65,5): error MSB4018: System.ArgumentException: Illegal characters in path.\r
    C:\SomePath\packages\Baseclass.Contrib.Nuget.Output.2.3.0\build\net40\Baseclass.Contrib.Nuget.Output.targets(65,5): error MSB4018:    at System.Security.Permissions.FileIOPermission.EmulateFileIOPermissionChecks(String fullPath)\r
    C:\SomePath\packages\Baseclass.Contrib.Nuget.Output.2.3.0\build\net40\Baseclass.Contrib.Nuget.Output.targets(65,5): error MSB4018:    at System.Security.Permissions.FileIOPermission.QuickDemand(FileIOPermissionAccess access, String[] fullPathList, Boolean checkForDuplicates, Boolean needFullPath)\r
    C:\SomePath\packages\Baseclass.Contrib.Nuget.Output.2.3.0\build\net40\Baseclass.Contrib.Nuget.Output.targets(65,5): error MSB4018:    at System.IO.FileSystemEnumerableIterator`1..ctor(String path, String originalUserPath, String searchPattern, SearchOption searchOption, SearchResultHandler`1 resultHandler, Boolean checkHost)\r
    C:\SomePath\packages\Baseclass.Contrib.Nuget.Output.2.3.0\build\net40\Baseclass.Contrib.Nuget.Output.targets(65,5): error MSB4018:    at System.IO.Directory.EnumerateFiles(String path, String searchPattern, SearchOption searchOption)\r
    C:\SomePath\packages\Baseclass.Contrib.Nuget.Output.2.3.0\build\net40\Baseclass.Contrib.Nuget.Output.targets(65,5): error MSB4018:    at Baseclass.Contrib.Nuget.Output.Build.PackageRetrievalTask.GetFilteredProjectNugetPackages(NugetPackageSource currentNugetPackageSource, HashSet`1 usedNugetPackages)\r
    C:\SomePath\packages\Baseclass.Contrib.Nuget.Output.2.3.0\build\net40\Baseclass.Contrib.Nuget.Output.targets(65,5): error MSB4018:    at Baseclass.Contrib.Nuget.Output.Build.PackageRetrievalTask.Execute()\r
    C:\SomePath\packages\Baseclass.Contrib.Nuget.Output.2.3.0\build\net40\Baseclass.Contrib.Nuget.Output.targets(65,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()\r
    C:\SomePath\packages\Baseclass.Contrib.Nuget.Output.2.3.0\build\net40\Baseclass.Contrib.Nuget.Output.targets(65,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
  Done executing task "PackageRetrievalTask" -- FAILED.
Done building target "CollectNugetOutputFiles" in project "DataArk.Infrastructure.Passwords.csproj" -- FAILED.

@mqtwinter
Copy link

mqtwinter commented Jul 26, 2017

Adding the SolutionDir property with the correct value to my msbuild deploy call made things work.

@fabiosalvi
Copy link

@gralov @cweb187 @mqtwinter see issue #39

@romerod
Copy link
Member

romerod commented Aug 10, 2017

@gralov is @mqtwinter resolution ok for you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants