Keeping Nuget packages updated in many projects/solutions - nuget

If using the same nuget package(s) over multiple solutions, how do I keep them up to date without having to open up every solution and update packages when a new version is released?
Folder structure is typically something like this but over many more projects. Each project has its own packages.config with various package references.
$tfs/
├── Solution One/
│ ├ Solution 1.sln
│ ├ nuget.config (solution item)
│ ├── Packages/
│ ├ ├── Newtonsoft.JSON.12.0.2/
│ ├ ├── Jquery3.1.4/
│ ├── Project one/
│ ├ ── packages.config
│ ├ ── whatever.cs
│ ├ ── folder /
│ ├ ── another folder /
│ ├── Project Two/
│ ├ ── packages.config
│ ├ ── file.cs
│ ├ ── folder/
│ ├ ── another folder/
├── Solution Two/
│ ├ Solution 2.sln
│ ├ nuget.config
│ ├── Packages/
│ ├ ├── Newtonsoft.JSON.11.1.0/
│ ├ ├── Jquery1.3.4/
│ ├── Project one/
│ ├ ── packages.config
│ ├ ── whatever.cs
│ ├ ── folder /
│ ├ ── another folder /
│ ├── Project two/
│ ├ ── packages.config
│ ├ ── file.cs
│ ├ ── folder/
│ ├ ── another folder/
I have tried running this powershell in Package Manager Console but this only applies to one solution at a time:
$packageId = "jquery"
Get-ChildItem *.sln -recurse | %{.\\nuget.exe restore $_.fullname}
Get-ChildItem packages.config -Recurse `
| Where-Object {$_ | Select-String -Pattern $packageId} `
| %{.\\nuget.exe update -Id $packageId $_.FullName}
Do I need to update packages.config in each solution of each project and open them in order to get the updates? I would have thought there would be an easier way to do this. I am using a private nuget server if it makes a difference.
Note: I have looked at this question: Updating nuget packages in all projects in a solution and it is not the same scenario as mine. I'm looking to update packages across multiple solutions, not multiple projects in one solution.

As #imps said in the comments, there's no solution for packages.config projects across solutions. Within a solution you can use the NuGet Package Manager UI's "Manage packages for solution" and the consolidate tab helps makes sure all projects use the same version, but you'll need to repeat this for all solutions.
If you migrate from packages.config to PackageReference, you could take advantage of MSBuild extensibility and either import a common props file, or if using Visual Studio 2017 or newer, use Directory.Build.Props in the highest common parent directory of all the projects.
In your props file, you define the versions of the packages you care about, something like this:
<Project>
<PropertyGroup>
<NewtonsoftJsonVersion>12.0.1</NewtonsoftJsonVersion>
</PropertyGroup>
</Project>
and then in your csproj files, use <PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonVersion)" />. The issue with this is that you can no longer use the Package Manager UI or Package Manager Console in VS to upgrade (well you can, but it'll change it in the csproj, not your props file), but you can still use the UI to check for updates. If you add your props file to your solution, then it just takes two clicks and a few taps on your keyboard to update, so it's really not a big deal.
In your example, the common parent directory would be the TFS root, so $/Directory.Build.props. The problem with this is if you use CI and have a trigger to run the Solution One build on changes to $/Solution One/* and run the Solution Two build on changes to $/Solution Two/*, then they'll both miss changes to $/Directory.Build.props. Or maybe it is possible to configure TFS build triggers to include it, but I don't remember because I haven't used TFVC is such a long time.
However, the bigger issue is that in your example, it's clear you're using the jQuery package. This uses content, which copies files into your project on install/upgrade. PackageReference doesn't work this way (it's listed as a package compatibility issue) , so unless you want to have a different process for upgrading jQuery and any other js/css in your web projects, you can't migrate ASP.NET projects to PackageReference. Note that ASP.NET Core projects are SDK style which only support PackageReference, not packages.config, and typically use either LibMan or npm to get css and javascript.
Customers who can migrate to SDK style projects, they could even consider using this SDK for central package management that helps ensure you don't accidently leave a version number in your csproj.

Related

How to reset a layout in svelte/kit with vite

If I have a main layout "+layout.svelte" at /routes and then try to reset the layout at /routes/auth/login It is not working.
If the name is "+layout.svelte" the layout is embedding inside the main layout.
If the name is "+layout#.svelte" it's not working.
If the name is "+layout.reset.svelte" its: Error: Files prefixed with + are reserved.
Because the default configuration of svelte/kit is vite. I think they changed it, but I don't know how to do it.
Only thing I can find in the docs about resetting layouts.
At: kit.svelte.dev/docs/advanced-routing#advanced-layouts-layout
Stuff has happened in the world since the accepted answer was posted. This is also true for Svelte/kit. Now there is something called (group) that looks like this:
src/routes/
│ (app)/
│ ├ dashboard/
│ ├ item/
│ └ +layout.svelte
│ (marketing)/
│ ├ about/
│ ├ testimonials/
│ └ +layout.svelte
├ admin/
└ +layout.svelte
This lets you group layouts in directories that has its name wrapped in parenthesis (that don't affect the routing). Here a +layout.svelte file inside such a directory will add to the src/+layout.svelte file - this layout wraps all other layout files defined in grouped directories.
Once you wrap your head around it, it is very easy to use. Read more about it in the documentation for advanced routing / advanced layouts
you need to create login layout at routes as +layout-login.svelte and refer on login page as +page#login.svelte

Adding codeowners for files in the root directory only

If I have a project structured like this:
project
│ README.md
│ config.json
package.json
│
└───folder1
│ │ fileA.js
│ │ fileB.html
│
└───folder2
│ fileC.js
│ fileD.html
How can I add a rule to the CODEOWNERS file that gives a user ownership of only the files in the root folder, but not the files in any of the subdirectories?
I've tried the following but none of them seem to work the way I want:
# CODEOWNERS
/ #johnSmith
./ #johnSmith
/* #johnSmith
After some experimenting this seems to work:
#CODEOWNERS
/*.* #userName
/apps #differentUserName
That will give #userName ownership of root files. It also applies to files inside dot-prefix folders, like .github/ or .vscode/ but no other nested directories

unresolved import for module imports in Visuial Studio Code

I have opened a folder in VS code and I am trying to set it up.
It's a python project and its directory structure is as:
Project
├── common_features
│ ├── ...
├── core
│ ├── features
│ └── main.py
│ └── tests
├── django project
│ ├── django_app1
│ ├── manage.py
│ ├── ...
└── tests
│ ├── ...
└── runner.py
The project runs as a django project from the django_project dir. It uses modules located in common_features and core. Core is designed such that it could also run on its own. You can also run core from runner.py
The problem is that all our module imports are not being resolved but 3rd party packages work well.
unresolved import 'core.config' Python(unresolved-import)
In PyCharm, I have marked Project, core and django_project as "sources root" and it works like a charm. Not sure how to do that in VS code.
I have tried making some changes in launch.json and settings.json but none are working. I am new to VS code so I'm unable to understand what it is that I'm doing wrong.
Thanks.
Can you try adding the following line to your settings.json file?
{
"python.autoComplete.extraPaths": ["./src"]
}
More info about this here: https://github.com/microsoft/python-language-server/blob/master/TROUBLESHOOTING.md#unresolved-import-warnings

.dot-prefixed directories in NuGet packages?

Currently I have a bunch of files living in a directory under TFS. Essentially I want to make a NuGet package out of it in my build server.
I do want however to move the file structure into a sub-directory and re-base from there. Let me explain:
The TFS path watched is: $/Foo/Bar/
$/Foo/Bar/
│
│ Bar.nuspec
│
└───PackageContent/
│ GenPumpGraphCtrl.dll
│ MultiPumpCurve.dll
│ PumpGraphCtrl2.dll
│
├───Dwg/
│ Logofnt1.wmf
│ LOGOFNT1a.wmf
│ LOGOFNT1b.wmf
│
├───Ref/
│ AqSolutions.xbn
│ Astring.bin
│ WordTranslation.xbn
│
└───Temp/
│
└───Notes/
Notes.txt
My .nuspec uses:
<files>
<file src="PackageContent\**"/>
</files>
However, I want to rename the PackageContent directory to .package-content and updated my .nuspec:
<files>
<file src=".package-content\**"/>
</files>
But by NuGet Pack step in TeamCity complains with the following error:
>> Cannot create a package that has no dependencies nor content.
Are .dot-prefixed directories somewhat hidden from TFS?
Are .dot-prefixed directories automatically ignored by the some obscure rule in the .nuspec?
Further investigation into the problem shows that in fact, if I place any .dot-prefixed directory, it gets entirely excluded from my NuGet package, despite using a wildcard.
The question is clearer now: How can I ensure I really include everything? Including .dot-prefixed directories?
Ok, in fact there is this obscure -NoDefaultExcludes parameter for nuget pack.
In my case, I had to add it to the Command line parameters box for the TeamCity NuGet Pack step:

PowerShell: How to install the DSC Resource Kit Wave 8 modules?

I am trying to set up a DSC pull server on Windows 2012 R2 machine by following this technet article:
http://technet.microsoft.com/en-us/library/dn249913.aspx
However I just can't get the modules working. The installation instructions says:
To install all DSC Resource Kit Modules, unzip the content under
$env:ProgramFiles\WindowsPowerShell\Modules
To confirm installation run Get-DSCResource to see that all of the
resources on this page are among the DSC Resources listed.
So I copied the content of the 'DSC Resource Kit Wave 8 10282014' folder to C:\Program Files\WindowsPowerShell\Modules which now looks as follows:
c:\Program Files\WindowsPowerShell\Modules>tree
├───cFileShare
│ ├───DSCResources
│ │ ├───VSAR_cCreateFileShare
│ │ └───VSAR_cSetSharePermissions
│ ├───Examples
│ ├───ResourceDesignerScripts
│ └───Unit Tests
├───xActiveDirectory
│ ├───DSCResources
│ │ ├───MSFT_xADDomain
│ │ ├───MSFT_xADDomainController
│ │ ├───MSFT_xADDomainTrust
│ │ ├───MSFT_xADUser
│ │ └───MSFT_xWaitForADDomain
│ └───Misc
├───xAdcsDeployment
│ ├───DSCResources
│ │ ├───MSFT_xAdcsCertificationAuthority
│ │ └───MSFT_xAdcsWebEnrollment
│ └───xCertificateServices
│ ├───DSCResources
│ │ ├───MSFT_xAdcsCertificationAuthority
│ │ └───MSFT_xAdcsWebEnrollment
│ └───Examples
[...]
Then I restarted my PowerShell console to ensure it's reloading $env:PSModulePath which contains this by the way (added linewrap manually for better readability):
PS C:\Users\Administrator> $env:PSModulePath
C:\Users\Administrator\Documents\WindowsPowerShell\Modules;
C:\Program Files\WindowsPowerShell\Modules;
C:\Windows\system32\WindowsPowerShell\v1.0\Modules\
So everything is pretty much default here. However get-module -ListAvailable is just not listening any of the above modules e.g. xPSDesiredStateConfiguration. Also the Get-DscResource cmdlet is not returning any ressources that come with this module (especially xDSCWebService is the DSC resource I am looking for to setup the pull server).
If I manually copy the content of xPSDesiredStateConfiguration\DSCResources\* to one of the modules path folder's I do see the DSC resources. However the pull-server setup script (Sample_xDscWebService.ps1) fails. Opening the editor it shows me a syntax error near to:
Import-DSCResource -ModuleName xPSDesiredStateConfiguration
I just can't figure out what I am doing wrong here. So, how can I install the DSC Resource Kit?
I had the same problem. After installation of 3 updates (KB2894029, KB2894179 and KB2883200) everything works ;)
This issue seems to be related to some missing patches. Unfortunately I dont know which one. The link to the blog post below is mentioning KB2883200. But installing it on my system did not make a change.
However it works on another fully patched Windows 2012 R2 server. Unfortunatley I don't have an easy access at work to patch my manually installed server to the latest available.
http://blogs.msdn.com/b/powershell/archive/2013/12/26/holiday-gift-desired-state-configuration-dsc-resource-kit-wave-1.aspx
I had this error and fixed it!
See my blog post at http://tfl09.blogspot.com//2015/04/using-dsc-resource-kit-hot-fixes-may-be.html
That location points to the specific patches you need.