Skip to content

Use the $(UserProfile) MSBuild macro where possible#100

Closed
AArnott wants to merge 1 commit intoNuGetArchive:devfrom
AArnott:fix1095
Closed

Use the $(UserProfile) MSBuild macro where possible#100
AArnott wants to merge 1 commit intoNuGetArchive:devfrom
AArnott:fix1095

Conversation

@AArnott
Copy link
Copy Markdown
Contributor

@AArnott AArnott commented Aug 7, 2015

The MSBuild [projectname].nuget.targets files should use this macro instead of a hard-coded path that includes the username so that the generated file can be shared by multiple users.

Fix NuGet/Home#1095

I tried to write a unit test for this, but tests don't show up in the Test Explorer and I couldn't find a text file in the source tree explaining how to run them.

The MSBuild [projectname].nuget.targets files should use this macro instead of a hard-coded path that includes the username so that the generated file can be shared by multiple users.
@dnfclas
Copy link
Copy Markdown

dnfclas commented Aug 7, 2015

Hi @AArnott, I'm your friendly neighborhood .NET Foundation Pull Request Bot (You can call me DNFBOT). Thanks for your contribution!
You've already signed the contribution license agreement. Thanks!

The agreement was validated by .NET Foundation and real humans are currently evaluating your PR.

TTYL, DNFBOT;

@yishaigalatzer
Copy link
Copy Markdown

Please remove XML comments for private members
Add a test to verify scenarios (we just added support for relative paths)
Add comment for the purpose of this change

Cool change!

:ship it: When test is added

@deepakaravindr please merge when completed

@AArnott
Copy link
Copy Markdown
Contributor Author

AArnott commented Aug 7, 2015

Thanks for reviewing, @yishaigalatzer.

As I said in the pull request description, I tried adding a test but couldn't figure out how to run them. Can you please explain how I can run them?
Also, you said add a comment for the purpose of the change. I did so, in my commit message and in the pull request description. Where else would you like to see a comment?

@yishaigalatzer
Copy link
Copy Markdown

Comment in the code.

And I was hoping for a unit test not a functional test to make sure the paths resolve appropriately

@AArnott
Copy link
Copy Markdown
Contributor Author

AArnott commented Aug 7, 2015

@yishaigalatzer Yes, I'm hoping for a unit test as well. But again, I fail to understand how to run the tests. How can your unit tests be run?

And where would you like the code comment? Since you have a policy against commenting private members, and the only other line I touch is in the middle of a large expression. Personally, I'm in favor of documenting the private members, and would be happy to add an xml doc comment to the private static method I added. I'd also like to add argument validation for it, but I couldn't find any other example nearby of you doing this, so I tried my best to fit the mold. Although I guess I did document that private field, so I deviated on that regard and will correct.

@AArnott
Copy link
Copy Markdown
Contributor Author

AArnott commented Aug 7, 2015

One relevant question perhaps is where do I get DNX? It seems your project.json file defines a "test" command, but in my VS 2015 Developer Prompt, "dnx" isn't a command.

@AArnott
Copy link
Copy Markdown
Contributor Author

AArnott commented Aug 7, 2015

OK, so I finally found how to get DNX, and stumbled through till I figured out how to run the NuGet.Commands.Test project's tests. But it looks like they all fail:

NuGet.Commands.Test.UWPRestoreTests.UWPRestore_BlankUWPApp [FAIL]
Microsoft.Framework.Runtime.Roslyn.RoslynCompilationException : C:\Users\andarno\git\NuGet3\src\NuGet.Commands\RestoreCommand.cs(809,28): DNX,Version=v4.5.1 error CS0246: The type or namespace name 'JToken' could not be found (are you missing a using directive or an assembly reference?)
Stack Trace:
at NuGet.Commands.Test.UWPRestoreTests.UWPRestore_BlankUWPApp()
NuGet.Commands.Test.RestoreCommandTests.RestoreCommand_FrameworkImportRulesAreApplied [FAIL]
Microsoft.Framework.Runtime.Roslyn.RoslynCompilationException : C:\Users\andarno\git\NuGet3\src\NuGet.Commands\RestoreCommand.cs(809,28): DNX,Version=v4.5.1 error CS0246: The type or namespace name 'JToken' could not be found (are you missing a using directive or an assembly reference?)

@yishaigalatzer
Copy link
Copy Markdown

@emgarten can you jump in and help @AArnott

@emgarten
Copy link
Copy Markdown
Contributor

emgarten commented Aug 7, 2015

@AArnott are you able to run build.cmd in NuGet3? It should handle building and running all tests for you.

What version of DNX do you have installed? Paste the output from: dnx --version

@AArnott
Copy link
Copy Markdown
Contributor Author

AArnott commented Aug 8, 2015

dnx --version

Microsoft .NET Execution environment
Version: 1.0.0-beta6-12256
Type: CLR
Architecture: x86
OS Name: Windows
OS Version: 6.2.9200.0

I just ran build.cmd. It took quite a while, and ended up failing with this (which looks like an internal bug in dnx.exe)

Build succeeded.
0 Warning(s)
0 Error(s)

Time elapsed 00:00:04.2177813
Total build time elapsed: 00:00:04.3143808
Total projects built: 1
info: Copying NuGet.Versioning.3.1.2-t150808024426.nupkg
info: Copying NuGet.Versioning.3.1.2-t150808024426.symbols.nupkg
info: Copying dnxcore50\NuGet.Versioning.dll
info: Copying dnxcore50\NuGet.Versioning.pdb
info: Copying dnxcore50\NuGet.Versioning.xml
info: Copying net45\NuGet.Versioning.dll
info: Copying net45\NuGet.Versioning.pdb
info: Copying net45\NuGet.Versioning.xml
info: Target native-compile
info: Target compile
info: Target test-compile
info: Target xunit-test
info: Exec
info: program: cmd
info: commandline: /C dnx test
info: workingdir: test\NuGet.Commands.Test
System.NullReferenceException: Object reference not set to an instance of an object.
at Xunit.Runner.Dnx.Program.Main(String[] args)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.Dnx.Runtime.Common.EntryPointExecutor.Execute(Assembly assembly, String[] args, IServiceProvider serviceProvider)
at Microsoft.Dnx.ApplicationHost.Program.ExecuteMain(DefaultHost host, String applicationName, String[] args)
at Microsoft.Dnx.ApplicationHost.Program.Main(String[] args)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.Dnx.Runtime.Common.EntryPointExecutor.Execute(Assembly assembly, String[] args, IServiceProvider serviceProvider)
at Microsoft.Dnx.Host.Bootstrapper.RunAsync(List1 args, IRuntimeEnvironment env, FrameworkName targetFramework) at Microsoft.Dnx.Host.RuntimeBootstrapper.ExecuteAsync(String[] args, FrameworkName targetFramework) at Microsoft.Dnx.Host.RuntimeBootstrapper.Execute(String[] args, FrameworkName targetFramework) warn: Exit code 1 from cmd verbose: Stack trace: at Viewf7ec52faf30141c38567f3e0ae8cadf6.K(String command, String workingdir, String dnvmUse) in c:\Users\andarno\AppData\Local\Temp\e59ec 1318fc74c09a6ac85a7b45c8071-1.cs:line 1230 at Viewf7ec52faf30141c38567f3e0ae8cadf6.DnxTest(String projectFile, Boolean testParallel) in c:\Users\andarno\AppData\Local\Temp\e59ec131 8fc74c09a6ac85a7b45c8071-1.cs:line 439 at Viewf7ec52faf30141c38567f3e0ae8cadf6.<RenderViewLevel0>b__6e(String projectFile) in c:\Users\andarno\AppData\Local\Temp\e59ec1318fc74c 09a6ac85a7b45c8071-1.cs:line 7647 at System.Collections.Generic.List1.ForEach(Action1 action) at Viewf7ec52faf30141c38567f3e0ae8cadf6.<RenderViewLevel0>b__6c() in c:\Users\andarno\AppData\Local\Temp\e59ec1318fc74c09a6ac85a7b45c8071 -1.cs:line 7647 at Sake.Engine.Builder.BuilderBase1.CallTarget(String name)
at Sake.Engine.Builder.BuilderBase1.StartingTarget(String name) at Viewf7ec52faf30141c38567f3e0ae8cadf6.<RenderViewLevel0>b__4e() in c:\Users\andarno\AppData\Local\Temp\e59ec1318fc74c09a6ac85a7b45c8071 -1.cs:line 1846 at Sake.Engine.Builder.BuilderBase1.CallTarget(String name)
at Viewf7ec52faf30141c38567f3e0ae8cadf6.b__46() in c:\Users\andarno\AppData\Local\Temp\e59ec1318fc74c09a6ac85a7b45c8071
-1.cs:line 1702
at Sake.Engine.Builder.BuilderBase`1.CallTarget(String name)
at Sake.Engine.SakeEngine.Execute(Options options)
at Sake.Engine.SakeEngine.Execute(String[] args)
at Sake.Program.Main(String[] args)

@emgarten
Copy link
Copy Markdown
Contributor

emgarten commented Aug 8, 2015

This is an xunit issue (or xunit/dnx combination issue). I've resolved it in the past by clearing out the %userprofile%.dnx\packages folder and removing all other sources apart from nuget.org. The error can happen when an incompatible version of xunit gets added to the global packages folder, normally through the aspnetvnext feed.

@davidfowl
Copy link
Copy Markdown
Contributor

The null ref looks like a version mismatch between xunit and the dnx being run.

@yishaigalatzer
Copy link
Copy Markdown

@AArnott are you able to make progress here?

@AArnott
Copy link
Copy Markdown
Contributor Author

AArnott commented Aug 14, 2015

I haven't had more time to spend on this. Feel free to build on the product change I've done by adding tests yourself if you'd like.

@deepakaravindr
Copy link
Copy Markdown
Contributor

Ported with NuGet/NuGet.Client#31

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants