ASP.net Include file which comes under exclude condition - c#

I need to exclude certain dll's from the package which I am building. But I need to include only this dll - System.Threading.Tasks.Extensions. Is there a way I can force this dll in Include which would supersede exclude command.
<files>
<file src="**\*.dll" include ="**\System.Threading.*" exclude="**\System.*;**\Azure.*;**\Microsoft.Bcl.*;**\Microsoft.IdentityModel.*;**\BouncyCastle*.dll;**\GraphQL.*;**\LaunchDarkly.*;**\Oracle.*.dll;**\xunit*.dll;**\*Tests.dll;**\obj\**\*.*;**\itextsharp.dll;**\AjaxControlToolkit.dll;**\Newtonsoft.Json.dll;**\log4net.dll;**\Npgsql.dll" target="lib\net48" />
</files>

Related

UWP Class Library NuGet package XamlParseException error

Currently I'm working on an UWP NuGet package for making it easier to create great popups and dialogs.
Currently the project is newborn and doesn't have so much controls but I tried to create a NuGet package for it to be a test for making sure it is all good.
Unless I'm using app with the class library referenced to the sample project all things working well but after downloading the library from NuGet I'm getting XamlParseException error.
I searched a bit and find it out that I should add some xaml, xbf or somethings in the output so I tried to add the following lines to my nuspec.
<files>
<!-- XAML controls -->
<file src="Controls\MessageBoxControls\MessageBoxControl.xaml" target="lib\netcore50\Controls\MessageBoxControls"/>
<file src="bin\Debug\UWPPopupToolkit\Controls\MessageBoxControls\MessageBoxControl.xbf" target="lib\netcore50\Controls\MessageBoxControls"/>
<file src="Controls\PopupControlControls\PopupControl.xaml" target="lib\netcore50\Controls\PopupControlControls"/>
<file src="bin\Debug\UWPPopupToolkit\Controls\PopupControlControls\PopupControl.xbf" target="lib\netcore50\Controls\PopupControlControls"/>
<file src="Controls\SlideupPopupControls\SlideupPopup.xaml" target="lib\netcore50\Controls\SlideupPopupControls"/>
<file src="bin\Debug\UWPPopupToolkit\Controls\SlideupPopupControls\SlideupPopup.xbf" target="lib\netcore50\Controls\SlideupPopupControls"/>
</files>
But still I'm getting same error any idea how to solve it?
I should mention that the project is currently available on Github on the following link
https://github.com/NGame1/UWPPopupToolkit
and the NuGet package also is available here
https://www.nuget.org/packages/UWPPopupToolkit
Simply placing the content files in the lib folder of the nuget package will not automatically copy it into the build output folder, only the dll, pdb and xml files will be added into the output projects automatically.
Since your additional files are not the same type, so you cannot get what you want by your method. So I suggest you could try this:
Solution
1) create a folder called build on your root directory of your project and then add a file called <package_id>.props file.
Note: the file must be named the same as your nuget package so that it will work. For an example, if your nuget project named as UWPPopupToolkit.0.0.1-rc.nupkg, the file must be named as UWPPopupToolkit.props.
2) add these content into the UWPPopupToolkit.props file:
<Project>
<Target Name="OutputExtraFiles" BeforeTargets="Build">
<ItemGroup>
<File Include="$(MSBuildThisFileDirectory)..\File\**\*.*"></File>
</ItemGroup>
<Copy SourceFiles="#(File)" DestinationFiles="$(TargetDir)\%(RecursiveDir)%(Filename)%(Extension)"></Copy>
</Target>
</Project>
3) modify your UWPPopupToolkitSDK.nuspec file like this:
<files>
<!-- XAML controls -->
<file src="Controls\MessageBoxControls\MessageBoxControl.xaml" target="File\Controls\MessageBoxControls"/>
<file src="bin\Debug\UWPPopupToolkit\Controls\MessageBoxControls\MessageBoxControl.xbf" target="File\Controls\MessageBoxControls"/>
<file src="Controls\PopupControlControls\PopupControl.xaml" target="File\Controls\PopupControlControls"/>
<file src="bin\Debug\UWPPopupToolkit\Controls\PopupControlControls\PopupControl.xbf" target="File\Controls\PopupControlControls"/>
<file src="Controls\SlideupPopupControls\SlideupPopup.xaml" target="File\Controls\SlideupPopupControls"/>
<file src="bin\Debug\UWPPopupToolkit\Controls\SlideupPopupControls\SlideupPopup.xbf" target="File\Controls\SlideupPopupControls"/>
<file src="build\UWPPopupToolkit.props" target="build" />
</files>
4) then repack your nuget project, before you install the new version of the nuget package, please clean the nuget caches first and also delete the bin, obj or any output folders of your main project.
=================================
Update 1
In my side, clean all nuget caches or delete all cache files under C:\Users\xxx(current user)\.nuget\packages and then install the new version of the nuget package, the target files are output to bin\x86\Debug\Controls,
If I install the new version 0.0.1.5-rc,everything works well. See this:
Not sure if your problem is that the files are missing or you want to put them into bin\x86\Debug\netcore50\Controls.
If your issue is the second, you should modify your UWPPopupToolkit.props,
use this:
<Copy SourceFiles="#(File)" DestinationFiles="$(TargetDir)netcore50\%(RecursiveDir)%(Filename)%(Extension)"></Copy>
After that, delete bin and obj folder and then rebuild your main project again.
Thanks to #Perry Qian-MSFT
Finally, I got able to fix the issue.
adding files like this
<files>
<!-- Dll -->
<file src="bin\Release\UWPPopupToolkit.dll" target="lib\netcore50" />
<!-- Resources -->
<file src="bin\Release\UWPPopupToolkit.pdb" target="lib\netcore50" />
<file src="bin\Release\UWPPopupToolkit.pri" target="lib\netcore50" />
<!-- IntelliSense -->
<file src="bin\Release\UWPPopupToolkit.XML" target="lib\netcore50" />
<!-- XAML control -->
<file src="bin\Release\UWPPopupToolkit\**\*.*" target="lib\netcore50\UWPPopupToolkit" />
<!-- Icon -->
<!--<file src="..\icon.png" target="images\" />-->
</files>
solved the problem.
You can find the result files here: UWPPopupToolkitSDK.nuspec | UWPPopupToolkit.props | UWP Popup Toolkit Github

Include *.resource.dll in nuget packages

When creating nuget package, I want to include all resources files.
Is it possible without specify one by one with tag in the .nuspec file ?
Maybe with wildcards ?
Just use some form of a wildcard. Here's an example I found.
<?xml version="1.0"?>
<package>
<metadata>...
</metadata>
<files>
<file src="lib\**" target="lib" />
</files>
</package>

Nuget Readonly Resources

I'm creating a DTO generator to be shared between projects I have a ttinclude file with some logic in it. In my nuspec I'm including files like so:
<files>
<file src="T4Generators\AutoMapperExtensions.ttinclude" target="content\T4Generators\AutoMapperExtensions.ttinclude"/>
<file src="T4Generators\ConstGenerator.ttinclude" target="content\T4Generators\ConstGenerator.ttinclude"/>
<file src="T4Generators\DTOGenerator.ttinclude" target="content\T4Generators\DTOGenerator.ttinclude"/>
<file src="T4Generators\EnumGenerator.ttinclude" target="content\T4Generators\EnumGenerator.ttinclude"/>
</files>
Is there a way to make these files read-only, since they are shared between projects people have a tendency to make changes to the include instead of going to my source (this is an internal resource).

unwanted culture specific dlls copied to bin directory

I am using visual studio 2013 & Fluent Validation 5.6.2
I see that after build in the bin folder it copies all the culture specific FluentValidation.resources.dll which seems to be mentioned it in .nuspec file
> <file src="lib\NET35\de\FluentValidation.resources.dll"
> target="lib\NET35\de\FluentValidation.resources.dll" />
> <file src="lib\NET35\es\FluentValidation.resources.dll" target="lib\NET35\es\FluentValidation.resources.dll" />
> <file src="lib\NET35\fr\FluentValidation.resources.dll" target="lib\NET35\fr\FluentValidation.resources.dll" />
> <file src="lib\NET35\it\FluentValidation.resources.dll" target="lib\NET35\it\FluentValidation.resources.dll" />
> <file src="lib\NET35\nl\FluentValidation.resources.dll" target="lib\NET35\nl\FluentValidation.resources.dll" />
> <file src="lib\NET35\pt\FluentValidation.resources.dll" target="lib\NET35\pt\FluentValidation.resources.dll" />
> <file src="lib\NET35\sv\FluentValidation.resources.dll" target="lib\NET35\sv\FluentValidation.resources.dll" />
But I do not need these in bin folder, because project does not support any culture specific messages.
So how can I tell vs-build to ignore these culture specific dlls?
My solution was to add this target at the end of the .csproj file before the closing project tag.
<Target Name="AfterPackage" AfterTargets="CopyAllFilesToSingleFolderForPackage" />
<ItemGroup>
<FluentValidationExcludedCultures Include="cs;da;de;es;fa;fi;fr;it;ko;mk;nl;pl;pt;ru;sv;tr;zh-CN">
<InProject>false</InProject>
</FluentValidationExcludedCultures>
</ItemGroup>
<Target Name="RemoveTranslationsAfterBuild" AfterTargets="AfterBuild">
<RemoveDir Directories="#(FluentValidationExcludedCultures->'$(OutputPath)%(Filename)')" />
</Target>
<Target Name="RemoveTranslationsAfterPackage" AfterTargets="AfterPackage">
<RemoveDir Directories="#(FluentValidationExcludedCultures->'$(_PackageTempDir)\$(OutputPath)%(Filename)')" />
</Target>
It's not pretty, but it gets the job done. If you need some culture specific resource, just remove the corresponding line from the list. If a future update adds a new culture that you don't want, add it to the list.
The best option would be ask the developer to separate the resources in multiple nugets, this way you could just add the ones needed. I'll stick with this solution, for now, until someone come up with a better one.
Now you can find my solution at the official project wiki: https://github.com/JeremySkinner/FluentValidation/wiki/f.-Localization (at the bottom of the page)
i had same problem with external library, i'm add post-build script in Visual Studio project properties, which delete all folders (for me it`s okay, otherwise set list of dirs) at output directory:
FOR /D %%d IN ($(TargetDir)*) DO RMDIR /S /Q %%d

More than one file cannot use an automatically generated guid unless a versioned file is the keypath and the other files are unversioned. Error

I have a C# solution with 4 projects there is only a single dll created for 3 of the projects and an exe from the main project. I've never used WIX but followed the simple example and was able to compile my code but only the .exe is deployed. I've tried modifing to add the other projects:
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<Component Id="ProductComponent">
<File Source="$(var.MedusaPerfApp.TargetPath)" />
<File Source="$(var.CustomClassLibrary.TargetPath)" />
<File Source="$(var.CustomControls.TargetPath)" />
<File Source="$(var.MultitaskingFramework.TargetPath)" />
</Component>
</ComponentGroup>
</Fragment>
I get the following error:
Error 3 The Component/#Guid attribute's value '*' is not valid for this component because it does not meet the criteria for having an automatically generated guid. Components with more than one file cannot use an automatically generated guid unless a versioned file is the keypath and the other files are unversioned. This component has a non-keypath file that is versioned. Create multiple components to use automatically generated guids.
As the error message says: Create multiple components to use automatically generated guids. Put each File element in its own Component element.
I came across the same problem and found a solution without having to wrap each file in a component tag. All you have to do is add a Guid to the component.
<Component Id="appComponent" Guid="6263db4e-4c67-4adc-9ef1-e1caef798331">
Here is an example you can follow

Categories