msbuild Assembly number - Get wrong number - msbuild

I have the following code in my CommonAssemblyInfo.cs
using System.Reflection;
using System.Resources;
using System.Runtime.InteropServices;
[assembly: AssemblyCompany("XXXX")]
[assembly: AssemblyProduct("BuildVersionTest")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCopyright("Copyright 2012")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: AssemblyVersion("4.0.*")]
[assembly: AssemblyFileVersion("4.0.6.121017")]
[assembly: AssemblyInformationalVersion("4.0.0.0")]
In my project I have this file linked and I also have the assemblyinfo.cs
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("BuildToolUtility")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: Guid("cfgfsfdrf68e-5af7-44f0-b310-f8a8191465fd")]
when I the build my dll file Version has
4.0.6.55481
Why? shouldnt it have what is in my CommonAssemblyInfo.cs?
Check this picture:
http://postimage.org/image/nrtab3hk1/
and then in the output window it shows another verison???? I can get this.
10:11:52 AssemblyVersion:
10:11:52 ***** Start getting assemblyVersion *****
10:11:52 4.0.4673.16477
10:11:52 ***** Done getting assemblyVersion *****
10:11:52 BuildRepositoryZip:
10:11:52 ***** Start zipping deploy folder. Making package *****
10:11:52 4.0.4673.16477
10:11:52 Creating ZipFile: ..\..\4.0.4673.16477.zip
10:12:11 ***** Done zipping deploy folder. Making package *****

The number used by your version file attribute is too high, so its overflowing as its a Uint16.
You should see something like warning CS1607: Assembly generation -- The version '4.0.6.160017' specified for the 'file version' is not in the normal 'major.minor.build.revision' format.
So you cant use your raw svn revision number once your svn repo get old enough...

Related

Setting the assembly file version and assembly version using cc.net and msbuild

We are using cc.net (cruise control) and msbuild to build a click once application. This is the msbuild task:
<msbuild>
<executable>C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe</executable>
<workingDirectory>D:\Directory</workingDirectory>
<projectFile>proj.lsxtproj</projectFile>
<buildArgs>/t:publish /p:PublishLocation=D:\Publish\;AssemblyFileVersion=$CCNetLabel;AssemblyVersion=$CCNetLabel</buildArgs>
<targets>Build</targets>
<timeout>600</timeout>
</msbuild>
So I am trying to set the assembly file version and assembly version of the published output.
The issue is that the variable $CCNetLabel does not seem to work. If I set AssemblyFileVersion and AssemblyVersion to something like 3.2.0.0 then the output has this version number but $CCNetLabel just does not work.
Has anyone got any ideas how to make this work?
Thanks
Ian
If the problem is that $(CCNetLabel) is blank try using the 'dynamic' variable. So instead of:
AssemblyFileVersion=$CCNetLabel;
use:
AssemblyFileVersion=$[$CCNetLabel];
Otherwise have a look at this other question which has more information re AssemblyInfo.cs and may help:
Using CCNetLabel to set AssemblyVersion and PublishVersion with CruiseControl.NET

Adding a custom font in Xamarin

According to this post: https://devblogs.microsoft.com/xamarin/embedded-fonts-xamarin-forms/
The new way to add a custom font is to add the font as an embeddedResource and then add this line in App.xaml.ca:
[assembly: ExportFont("DSEG7ModernRegular.ttf")]
But I get this error:
Error CS0246 The type or namespace name 'ExportFontAttribute' could not be found (are you missing a using directive or an assembly reference?)
My project references:
Xamarin.Essentials (1.3.1)
Xamarin.Forms (4.4.0.991265) - 4.5
NetStandard.Library (2.0.3)
ExportFontAttribute is in the Xamarin.Forms namespace, so be sure you have
using Xamarin.Forms;

The type or namespace name 'IWebHostEnvironment' could not be found (are you missing a using directive or an assembly reference?)

I am using .NET Core 3.0.100 ; Microsoft Visual Studio Community 2019 Preview Version 16.4.0 Preview 1.0 ; Blazor-server (official release).
I am trying to add Authentication and Authorization to my Blazor-server web app. I am reading the guideline at here https://learn.microsoft.com/en-us/aspnet/core/security/authentication/scaffold-identity?view=aspnetcore-3.0&tabs=visual-studio#scaffold-identity-into-an-empty-project
(I also read this https://github.com/aspnet/Identity/issues/1825)
Then I right-click on Project, choose Add \ New Scaffolded Item...
I read the file ScaffoldingReadme.txt, then follow the guide.
I press F5 for debugging, I catch the error.
Severity: Error
Error Code: CS0246
Description: The type or namespace name 'IWebHostEnvironment' could not be found (are you missing a using directive or an assembly reference?)
Project: foo
File: C:\Users\donhuvy\Desktop\foo\bar\obj\Debug\netcoreapp3.0\Razor\Pages\Shared\_Layout.cshtml.g.cs
Line: 455
Suppression State: Active
Screenshot
Because file \obj\Debug\netcoreapp3.0\Razor\Pages\Shared\_Layout.cshtml.g.cs stand inside Razor Class Library Microsoft.AspNetCore.Identity.UI (3.0.0), I cannot edit it.
How to fix it?
This is an issue,
The code generate is
Microsoft.AspNetCore.Hosting
#using Microsoft.AspNetCore.Mvc.ViewEngines
#inject IWebHostEnvironment Environment
#inject ICompositeViewEngine Engine
it is missing #using
it should be
#using Microsoft.AspNetCore.Hosting
I reported issue at https://github.com/aspnet/Scaffolding/issues/1094
Issue solved by adding in our csproj file (3.1 core app):
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

CarouselView Xamarin Plugin not working

I am getting the following error:
Error CS0234: The type or namespace name 'CarouselView' does not exist
in the namespace 'Xamarin.Forms' (are you missing an assembly reference?)
(CS0234) (your project)
Using this on the XAML
xmlns:controls="clr-namespace:CarouselView.FormsPlugin.Abstractions;assembly=CarouselView.FormsPlugin.Abstractions"
Name of the package is: CarouselView.FormsPlugin.
Update......
xaml
As per the project documentation on GitHub, there are several steps you need to do to enable the plugin:
Install the package via NuGet
Initialize the plugin
On Universal Windows Platform include with Xamarin.Forms initialization:
List<Assembly> assembliesToInclude = new List<Assembly>();
assembliesToInclude.Add(typeof(CarouselViewRenderer).GetTypeInfo().Assembly);
Xamarin.Forms.Forms.Init(e, assembliesToInclude);
On iOS and Android right after Xamarin.Forms initialization:
Xamarin.Forms.Init();
CarouselViewRenderer.Init();
Use in XAML
For XAML usage, you need to include a different namespace (CarouselView.FormsPlugin.Abstractions) than you noted in the question:
xmlns:controls="clr-namespace:CarouselView.FormsPlugin.Abstractions;assembly=CarouselView.FormsPlugin.Abstractions"
And now use as:
<controls:CarouselViewControl ...>

Visual Studio 2017 and the new .csproj InternalsVisibleTo

Where do I put InternalsVisibleTo from AssemblyInfo in the new Visual Studio 2017 .csproj project file?
Just in case anyone would like to put InternalsVisibleTo within a .csproj file instead of AssemblyInfo.cs (a possible scenario is to have a naming convention between a project under test and a test project), you can do it like this:
<ItemGroup>
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
<_Parameter1>$(MSBuildProjectName).Test</_Parameter1>
</AssemblyAttribute>
</ItemGroup>
Having this the following code will be generated
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("MyProject.Test")]
inside auto-generated AssemblyInfo.cs (e.g. for Debug configuration and .NET Standard 2.0 target)
/obj/Debug/netstandard2.0/MyProject.AssemblyInfo.cs
Additional Info
In case you're on .NET Core 3.1 and this approach isn't working, you may have to explicitly generate assembly info by adding the following to your .csproj file:
<PropertyGroup>
<!-- Explicitly generate Assembly Info -->
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
</PropertyGroup>
As of .NET 5 (and newer .NET versions) this actually works once added to your csproj:
<ItemGroup>
<InternalsVisibleTo Include="YourProject.Tests.Unit" />
</ItemGroup>
Work and discussion around this feature can be seen on this PR on dotnet's GitHub repo.
To clarify Hans Passant's comment above, you simply have to add InternalsVisibleTo to any cs file in your project. For example, I created an AssemblyInfo.cs file in the root of the project and then added the following content (only):
using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=<ADD_KEY_HERE>")]