nuget.exe pack excludes files without a dot - windows-10

Running the command nuget.exe pack <path-to-nuspec> -NoDefaultExcludes -OutputDirectory <path-to-output-dir> on a Windows 10 machine does not include files without a dot, such as "Dockerfile". I have not been able to find any information on this, apart from information on how to include files starting with a dot.
Is it working as intended or am I missing some option? Seems like a strange limitation, gives that Dockerfile is something one might want to include in a nuget package.

I found a work-around for this. In the .nuspec file, just replace
<file src="include/**/*.*" target="include" />
with
<file src="include/**/*" target="include" />
It seems that '*' catches the "*.*" files as well.

Related

Ignore folders when packing a nuget package

Considering a project in Visual Studio with the following structure
Project
---Folder A
----- CS Files
---Folder B
----- CS Files
---Folder C
----- CS Files
All works great but I want to pack only content from Folder A and C, ignoring totally all .cs files from Folder B.
is that possible?
I tried the <file> and <contentFile> arguments in a nuspec file but that doesn't quite work.
<file> only added them as a extra file in the package and <contentFile> had no effect
How about this two lines
<file src="Folder A\*.cs" target="content\Folder A" />
<file src="Folder C\*.cs" target="content\Folder A" />
I had a similar problem and could use "exclude" to excluse all Tests.dll from my deployed dlls. But actually I do not know how to use it right to exclude the folder
Hope that helps

Changing build variants in bulk in AndroidStudio 3.0+

Quick history:
I'm using AndroidStudio 3.0
my project has 100+ modules (multiple applications and libraries).
all of them have same flavorDimensions and flavors.
Now question: how to change flavors for all modules in bulk in AndroidStudio 3.0+ without changing each application separately?
There are two settings in Android Studio to enable switching all variants at once when selecting the app variant.
The settings are "Only sync the active variant" & "Do not build Gradle task list during Gradle sync". Both of them need to be disabled, then I restarted Android Studio once and Gradle sync.
With the settings in the screenshot disabled, I went from switching and waiting for ~10 seconds per dynamic-feature module (10 in my project) to one single switch in <5 seconds.
Note: This is tested in Android Studio 4.0.1
Here is what I recently ended up doing:
close Android Studio
open a terminal
cd to the base directory of your project
replace all occurrences of <option name="SELECTED_BUILD_VARIANT" value="debug" /> with <option name="SELECTED_BUILD_VARIANT" value="release" /> or vice versa in all iml files. Here is a one liner to change all modules to release:
find . -name \*.iml | xargs perl -pi -e 's/<option\s+name="SELECTED_BUILD_VARIANT"\s+value="[^"]+"/<option name="SELECTED_BUILD_VARIANT" value="release"/'
to change back to debug run:
find . -name \*.iml | xargs perl -pi -e 's/<option\s+name="SELECTED_BUILD_VARIANT"\s+value="[^"]+"/<option name="SELECTED_BUILD_VARIANT" value="debug"/'
Open Android Studio again and do gradle sync
The build variant of all modules should be replaced now
Of course this approach makes assumptions about the formatting of an xml file which makes it a bit fragile. So far it seems to work well though.
You need a plugin called Build Variant Quick-Selector
Install Build Variant Quick-Selector (Settings->Plugins->Marketplace)
Build-> Switch All Build Variants...
I built the Build Variant Matrix Selector which, with all respect, I believe is faster to use than the ".. Quick Selector" mentioned above here. No duplicate drop downs, no hassle. Just select the variants from radio button in the matrix and go.
Just extending Marten's answer. It's a bit tedious to use command line and not see what you're doing. Just use vscode or any other text editor of your choice.
First close Android Studio (because it can revert the changes back to original)
Search for *.iml files that has the text below. Just make sure to include any folders which are ignored from git. vscode seems to ignore searching folders and files that are defined in .gittignore
<option name="SELECTED_BUILD_VARIANT" value="debug" />
then replace it debug/release whatever you want.
Open Android Studio and see changes are applied

How to restore nuget packages from network share in Linux Docker container

I'm tring to build a .NET Core solution in a Docker container but cannot get the dotnet restore command to work. I need to use both a local network share (just a simple filesystem repository) as well as the official nuget repo.
My nuget config looks like this:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="Nuget Feed" value="https://api.nuget.org/v3/index.json" />
<add key="custom feed" value="//uvd-fs1.uvd.local/Install/UVPackages" />
</packageSources>
</configuration>
I start the container using the command docker run -it --rm -v "$pwd\:/sln" microsoft/aspnetcore-build:latest
Then cd sln and dotnet restore ./UVAudit.sln.
This produces the following error:
/usr/share/dotnet/sdk/1.0.1/NuGet.targets(97,5): error : Failed to retrieve information about 'RavenDB.Client' from remote source '/uvd-fs1.uvd.local/Install/UVPackages'. [/sln/UVAudit.sln]
I would expect the RavenDB package to be restored from the official feed, but if I remove the custom package source from the nuget.config file, only the non-official packages cannot be resolved. This makes me think that the error message is a bit misleading. I would also think that the /uvd-fs1.uvd.local/Install/UVPackages part should in fact be //uvd-fs1.uvd.local/Install/UVPackages, but adding further slashes does nothing. Any ideas if I'm doing something wrong or this looks like a bug? I'm no Linux expert, so I might be missing some basic concept.
I also tried changing the repository path to smb://uvd-fs1.uvd.local/Install/UVPackages which caused the error message to change to:
/usr/share/dotnet/sdk/1.0.1/NuGet.targets(97,5): error : Failed to verify the root directory of local source 'smb://uvd-fs1.uvd.local/Install/UVPackages'. [/sln/UVAudit.sln]
/usr/share/dotnet/sdk/1.0.1/NuGet.targets(97,5): error : smb://uvd-fs1.uvd.local/Install/UVPackages [/sln/UVAudit.sln]
I don't really know if this even makes sense to try, just one of the very limited clues provided by googling.
UNC paths (\\..) are primarily a windows concept. While the underlying protocol for network und paths is smb, the NuGet client won't support it - the reason it works on windows is because the file system api handles UNC paths transparently.
If you want to restore reliably from a docker container, i suggest setting up a NuGet feed (there is a NuGet.Server nuget package for asp.net websites which is sufficient for small internal feeds).

File listed twice in rpm spec file

The files section of my spec-file looks like this:
%files
%{prefix}/htdocs/
%config %{prefix}/htdocs/share/settings/config.inc.php
Now, since the config file is already included in the %{prefix}/htdocs/ line I get the warning 'File listed twice'.
One way around would be, to list every single file within %{prefix}/htdocs/, except the config file.
But my question is: Is there a better way around this issue, than listing all files?
Unfortunately not. RPM is quite oldschool software, but works fine :-)
But you can use globs too:
%files
%{prefix}/htdocs/*.png
%{prefix}/htdocs/*.html
etc.
This will enable you to include all the rest without some other files you do not want there. That's the way how RPM packagers do it usually.

Is WindowsAzure.targets ValidateServiceFiles an essential build step?

We have a problem with our azure build such that we can only get it to work if we use absolute paths in the WebRole/Contents/Content/SourceDirectory sections of our csdef file. Although it does support relative paths (including '..') and environment variables (! Yes as in SET) the problem is we cant get any non-absolute path to successfully build because it appears the .csdef file is "validated" twice: once where it sits in the project directory before packaging, and once again after it had been moved to the /bin folder. Obviously there is no one relative path that will be able to resolve to the same content directories if we start in two separate places! What you can do is get the paths right for ONE of the two build steps phases... but then it will fail on the other. The offending target is PreValidateServiceModel which calls the ValidateServiceFiles task.
In order to make my project build using relative paths i need to disable the PreValidateServiceModel target. The packaging appears to work although I'm worried some vital process is being missed by skipping the targets (aside from the obvious... the service files are not validated!). That said the .csdef file is still "validated" in the sense it has to be parsed to create the package.
I had a similar problem. Checking the documentation on the Source directory element of the WebRole schema, I saw that environment variable expension in the directory path is supported. This led me to the following solution.
In a pre-build event of the project containing the csdef file, I copy my files from the UpdaterFiles directory to a directory under the Temp directory:
IF NOT EXIST %TEMP%\UpdaterFiles MKDIR %TEMP%\UpdaterFiles
XCOPY $(ProjectDir)..\UpdaterFiles\*.* %TEMP%\UpdaterFiles\ /Y
Then my source directory just becomes:
<SourceDirectory path="%TEMP%\UpdaterFiles" />
The above works like a charm
Here is a different solution, which avoids copying to temp.
As already mentioned, the problem is that the relative path does not work from two different places:
1. ProjectFolder\ServiceDefinition.csdef
2. ProjectFolder\bin\Debug\ServiceDefinition.csdef
So I moved the source location of ServiceDefinition.csdef down two folder levels, so that the same relative path will work in both cases:
1. ProjectFolder\Service\Definition\ServiceDefinition.csdef
2. ProjectFolder\bin\Debug\ServiceDefinition.csdef
To do this, I edited the project file (right click, 'Edit Project File') and changed:
<ServiceDefinition Include="ServiceDefinition.csdef" />
into:
<ServiceDefinition Include="Service\Definition\ServiceDefinition.csdef" />
I created those two sub-folders in Windows Explorer and moved the file to its new location. Then I reloaded the project.
I noticed that Visual Studio automatically added these two lines for me:
<Folder Include="Service\" />
<Folder Include="Service\Definition\" />
In my ServiceDefinition.csdef file, I refer to the source directory by going up three folders to the solution folder, and then navigating from there:
<SourceDirectory path="..\..\..\MySourceProject\MySourceFolder" />

Resources