How to fix Error MSB4044 The “FilterAssemblies” task was not given a value for the required parameter “DesignTimeBuild”

How to fix Error MSB4044 The “FilterAssemblies” task was not given a value for the required parameter “DesignTimeBuild”

If you updated your visual studio to version 16.2.0 and you are using MSBuildSdkExtras your project won’t compile.

so to fix this problem (this is a temporary fix). You need to add the following lines to your csproj

<PropertyGroup Label="Android DesignTimeBuild error workaround"> 
  <DesignTimeBuild>false</DesignTimeBuild>
</PropertyGroup>

 

 

How to automatically show a read me file after installing a NuGet

How to automatically show a read me file after installing a NuGet

There are times when you have been working on your new exciting project and it looks so good that you just want to release it as soon as possible so the world can be blessed with your new NuGet package but wait your new library is a complex library and require special setup instructions after it has been installed.

Well, we can solve that problem by adding a readme file with all the setup instructions, to do that add the following XML snippet to your csproj file, then you can just add a ReadMe.txt to your project. Now when the end-user install your NuGet package the read me file will automatically open

<ItemGroup>
<None Include="ReadMe.txt" pack="true" PackagePath="." />
</ItemGroup>
How to exclude package dependencies in a NuGet package

How to exclude package dependencies in a NuGet package

Sometimes during the development stage, you need to add package references to your project that are only needed either during the development or compilation stage but they are not actually required by the emitted assembly.

So how do we avoid to flood the end project with package dependencies that are actually not needed? Well the answer is super simple but is not obvious, so let’s see the following example

Now we can use the package explorer to open the package produced by the csproj above.

 

 

as you can see the package Newtonsoft.Json is included as a dependency since we include it on the csproj as package reference. So how can we fix that? the answer depend on how now you create your NuGet package, in this case, I’m going to focus my answer on excluding the dependency in a package created by the info in the csproj file (there is a different approach if you use the nuspec file).

To exclude a package reference you have to add the private asset attribute as shown in the image below.

 

<PackageReference Include="Newtonsoft.Json" Version="12.0.2">
  <PrivateAssets>all</PrivateAssets>
</PackageReference>

 

You can learn more about this attribute on the following link

Now if we open the package produced by the csproj above we will see that now there are not dependencies listed

So that is how we get rid of development dependencies, to learn more about how to package a NuGet I recommend the following link

https://docs.microsoft.com/en-us/nuget/reference/nuspec