Quantcast
Channel: MSBuild forum
Viewing all 2763 articles
Browse latest View live

linking across different /arch

$
0
0

Hi,

I was curious if there was a way /switch by which linking across different /arch values can be disabled or have a warning be printed. Since this can cause crashes when a newer instruction is run on an older CPU and is detected late in the game for large projects using different libraries.

We have a project which has /arch:IA32 but it links with a library with the default SSE2 and this crashes in field.

Thanks,


SS


Animating a button

$
0
0

Hi

im working on an interactive form and am hoping someone can help me with a part of it.

Id like to animate a form button so that when a mouse is hovered over it, it will grow, or shrink, etc.

Just wondering if anyone has any thoughts on how to go about doing it?

Any help would be appreciated

Thanks

Phantomfleece

MSBuild Project object for netstandard and netcoreapp

$
0
0

Hi, I use the library microsoft.build.evaluation.project to parse a .csproj files. but this library is compatible only to Net Framework.

Also, when I try to parse a file with 

<TargetFramework>netstandard2.0</TargetFramework>

I get this error:

Microsoft.Build.Exceptions.InvalidProjectFileException: 'The imported project "C:\Users{UserName}.nuget\packages\microsoft.testplatform.testhost\15.9.0\lib\netstandard1.5\15.0\Microsoft.Common.props" was not found. Confirm that the path in the declaration is <g class="gr_ gr_203 gr-alert gr_gramm gr_inline_cards gr_run_anim Punctuation only-del replaceWithoutSep" data-gr-id="203" id="203">correct,</g> and that the file exists on disk. C:\Program Files\dotnet\sdk\2.1.403\Sdks\Microsoft.NET.Sdk\Sdk\Sdk.props'

I realize this library does not support the new frameworks. There is any replacement for the library?


ברוך. baruchiro@gmail.com

Translate Sql Query to Clr

$
0
0

Hello,

How can I write the following query in c# clr ?

Thank you

CREATE FUNCTION SQL_HT(  @param1 INT,  @param2 INT)RETURNS@tablo TABLE(   colon1 VARCHAR(15),  colon2 INT)ASBEGIN   INSERT INTO @tablo (colon1,colon2)  SELECT 'D','1'  RETURNEND

using System;using System.Data;using System.Data.SqlClient;using System.Data.SqlTypes;using Microsoft.SqlServer.Server;public partial class UserDefinedFunctions{    [Microsoft.SqlServer.Server.SqlFunction]    public static SqlString SqlFunction2()    {        ???        return new SqlString (string.Empty);    }}


MSTest 1.4 affects web publish

$
0
0

I did
Install-Package MSTest.TestFramework -Version 1.4.0 

Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.dll
Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.dll
Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Interface.dll
ends up in the root and bin folder of my website after web publish.

WHY?

Do I need to purge something?


Referencing the same project in two solutions causes building of the second solution to fail

$
0
0

I am getting an error while building a complex project on a TFS build server. I was able to reproduce the error with a simpler setup that I'll be using here to describe the problem. Due to the age and complexity, the project still uses the build tools of Visual Studio 2010.

I have a repository with two solutions: WindowsProject1 and WindowsProject2, which are both MFC applications. I also added the project WindowsProjectTools to both solutions, because the dll is referenced by the main project in both.

The problem occurs when building the solutions on the build server like this: enter image description here

The first build step (WindowsProject1) succeeds, but the second (WindowsProject2) fails with the following errors:

enter image description here

Error C1090: PDB API call failed, error code '23' : '(

There are some questions on the web about this error, but never with a satisfactory solution.

I suspected that building WindowsProjectTools in both build steps will collide for some reason, maybe the intermediate folder intersects, so I changed it to $(SolutionDir)$(Configuration)\ but it did not help.

However, changing the build step order helps insofar that then building WindowsProject2 succeeds, but WindowsProject1 fails. This makes me believe that the solution and project files are in order, but that there is some setting in TFS that I am missing.

I have also tried to change MSBuild Version from Latest to 4.0 (the version associated with VS2010) without success.

Migrating to newer vs version is an obvious step. However, it would require massive ressources to migrate the entire project. I would like to avoid this step at this time.

Duplicate key row error with Team Foundation Server 2015 Build Server

$
0
0

My build server has been up and running for years without any problems. A couple weeks ago I started getting an intermittent error when building.

Cannot insert duplicate key row in object 'Task.tbl_AgentRequest' with unique index 'IX_Task_tbl_AgentRequest_PoolId_QueueTime'. The duplicate key value is (1, 10, 2018-12-20 19:47:17.6700000).

Doing a little research others have had this issue with varying degrees of success trying to fix it.

Things I have tried to try to fix this without success:

1) Rebooted TFS and the Build Server.

2) Deleted all Agent Pools, Agent Queues, and Agents and recreated them new.

3) Deleted all build scripts and recreated them new.

4) Modified the build scripts and unchecked the "Parallel" option in the Multi-configuration setting.

None of these things has fixed the problem, it is still occurring.

What I have discovered from investigating the problem on my server is that the build server is incorrectly starting 2 different builds at the same time.

For example:
Say I have 2 build Scripts A & B, each with 2 Build Configurations 1 & 2.
Both build scripts are queued to build at the same time.

The build agent start building "A-1".   "A-2" shows as queued.

The "All build definitions" screen "Queued" builds shows:
Build script A as Building
Build script B as Queued

When "A-1" finishes that is when the error occurs.

That is, what happens next seems to be randomly one of 4 possible outcomes:
a) B-1 starts building & A-2 remains Queued (is ok)
b) A-2 starts building & Script B remains Queued (is ideal)
c) B-1 starts building & A-2 has the duplicate key error and fails (is bad)
d) A-2 starts building & B-1 has the duplicate key error and fails (is bad)

The error appears to be that the 2nd build configuration and the next queued build script are both simultaneously starting on the same build agent resulting in one of them getting the error.

Again, this error has recently started happening on builds that have been good for years now.  Prior to the errors the builds would always complete all build configurations before moving on to the next queued build script.

This is on Microsoft Visual Studio Team Foundation Server Version 14.114.27412.0

Any help solving this issue is greatly appreciated.  Thanks!

Problems using MSBuild in a build server without any Visual Studio

$
0
0

Hi there.
Fisrt of all, I must mention that I am not a .NET analyst/developer.

Assuming that, I have the following scenario:

- I have a Win2008R2 server with all .NET Frameworks installed (version 1 up to 4.5) and also some Microsoft SDK's too;
- I simply need to run msbuild from a PowerShell command prompt in order to build different .sln files;
Example: ${msbuild_dir}/MSBuild ${solution_file} /t:Clean,Build /p:Configuration=Release /p:Platform="Any CPU";OutDir=${output_dir}

- For some .sln this command line is enough to get all compiled files. 
 Unfortunately for some others, I got stuck in the compiling process with one of the following errors:

1) Specified .targets files are not found on the server
It only varies the VS version, but many solutions stop the building process asking for one of these:

<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v9.0\WebApplications\Microsoft.WebApplication.targets" />
<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v11.0\WebApplications\Microsoft.WebApplication.targets" />

The easiest turn around I have found to solve this was to manually remove those references from the specified .csproj file.
After doing that and re-running the same command line above, the whole .sln compilation goes fine.
The question is: how can I avoid getting this error considering that:
- I cannot install any VS in the server;
- I cannot even copy these .targets files to MSBuild directory in the server;
- I must avoid removing that manually from the .csproj file.

2) Solution version is not up-to-date for MSBuild
Some .sln simply do not start compiling. I got the following error message:

MSB4054: The solution file must be opened in the Visual Studio IDE and converted to the 
latest version before it can be built by MSBuild.

Ok! That's easy and great! =)

The problem is:
- I have almost 200 different .sln files that are giving me this error;
- I do not have contact with the responsible developers that should solve that issue;

I just need to know if maybe there is a special parameter that I could change the solution version or if I must follow the message guide and change each one in VS manually.

Please if any of you guys could help me I would be very thankfull.

Regards,
Luis Santos






Error MSB4062 with VS2017 on Win10

$
0
0

Hi everyone, 

Here is the error when I trying to build vc++ solution with vs2017 on window10 OS:

MSB4062The "ValidateNTTargetVersion" task could not be loaded from the assembly C:\project1\master\w\camerasw\Universal\Program Files\Windows Kits\10\build\bin\Microsoft.DriverKit.Build.Tasks.15.0.dll. Could not load file or assembly 'Microsoft.DriverKit.Build.Tasks, Version=10.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. Strong name validation failed. (Exception from HRESULT: 0x8013141A) 
Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.

How can I solve this error? Thank you in advance!

FIPS issues in Windows, .NET, and Visual Studio

$
0
0

FIPS issues in Windows, .NET, and Visual Studio

(These are some issues and work-arounds I found while working with System.Security.Cryptography with FIPS enabled. Just wanted to pass them on to help anyone in a similar scenario.)

FIPS (Federal Information Processing Standard) is a standard defined by NIST (National Institute of Standards and Technology) that specifies the security requirements for cryptographic modules. The FIPS standards are often required when working with government data.

The following Microsoft articles provide some information on enabling/disabling the option and the affect it has.

  • System cryptography: Use FIPS compliant algorithms for encryption, hashing, and signing" security setting effects in Windows XP and in later versions of Windows

    • Note that the "Managed" version of the System.Security.Cryptography classes will error with FIPS:

      "Microsoft .NET Framework applications such as Microsoft ASP.NET only allow for using algorithm implementations that are certified by NIST to be FIPS 140 compliant. Specifically, the only cryptographic algorithm classes that can be instantiated are those that implement FIPS-compliant algorithms. The names of these classes end in "CryptoServiceProvider" or "Cng." Any attempt to create an instance of other cryptographic algorithm classes, such as classes with names ending in "Managed," cause an InvalidOperationException exception to occur. Additionally, any attempt to create an instance of a cryptographic algorithm that is not FIPS compliant, such as MD5, also causes an InvalidOperationException exception."
  • Why We’re Not Recommending “FIPS Mode” Anymore (read: "by default")
    Microsoft has decided not to enable FIPS by default…"we’re not telling customers to turn it off – our recommendation is that it’s each customer’s decision to make."
    This is likely due to the complications and problems it can cause for individuals and corporations who do not need to comply with governmental regulations for data processing.

Enabling/Disabling FIPS in Windows

Use the Group Policy Editor (gpedit.msc), set the following option to "Enabled".

This will set the "Enabled" REG_DWORD value to 1 under the following key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\FipsAlgorithmPolicy


Example and Resolving Issues with Visual Studio's Code Analysis

As stated above, the "Managed" cryptography classes are not FIPS compliant. For example, simply attempting to call the constructor for a SHA512Managed class will error:

Dim nonFIPSCompliantHasherAsNew System.Security.Cryptography.SHA512Managed()

The constructor, by design, throws an InvalidOperationException with a message like this: "This implementation is not part of the Windows Platform FIPS-validated cryptographic algorithms."

Instead, use one of the following:

               Dim cngHasherAsNew System.Security.Cryptography.SHA512Cng()

      Dim svcHasherAsNew System.Security.Cryptography.SHA512CryptoServiceProvider()

In some cases, such as RijndaelManaged, there may not be a valid implementation. This may require selection of a FIPS compliant alternative.

Note that the Microsoft Code Analysis functionality itself is not FIPS compliant. So, when enabling FIPS for testing in a development environment, you may receive compilation errors relating to this.

While it may take some trial and error, the work-around is to locate the related MSBuild.exe.config and disable the FIPS compliancy for it. For example, Visual Studio 2015 appears to use the following:

C:\Program Files (x86)\MSBuild\14.0\Bin\MsBuild.exe.config

Edit this file and in the <runtime> section, add/set the enforceFIPSPolicy option to false.

<configuration>                                                          
    <runtime>
        <!-- below tag will disable security policy checking for FIPS -->
        <enforceFIPSPolicy enabled="false"/>
    </runtime>
</configuration>

This same option can be used to disable FIPS enforcement in your application's app.config file. However, it's preferable to actually address your application's cryptography shortcomings rather than bypassing them.


Error MSB4024

$
0
0

I am receiving error MSB4024 -> 

ErrorMSB4024The imported project file "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Platforms\Win32\PlatformToolsets\v141_xp\Toolset.targets" could not be loaded. Unexpected end of file while parsing Comment has occurred. Line 48, position 1.com.mansingh_projectC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.Cpp.Platform.targets30

hence

--> there is an error for toolset.target -> also my tool set is not loading in the VB community 2017  

what might have caused toolset to failed. There is one more thing i am using 64 bit but due to project dependencies i may have to use 32 bit platform toolset .

MSBUILD : error MSB1021: Cannot create an instance of the logger

$
0
0

creating build (VS 2017) I am getting <g class="gr_ gr_66 gr-alert gr_gramm gr_inline_cards gr_run_anim Grammar only-ins doubleReplace replaceWithoutSep" data-gr-id="66" id="66">error</g> and <g class="gr_ gr_67 gr-alert gr_gramm gr_inline_cards gr_run_anim Grammar only-ins replaceWithoutSep" data-gr-id="67" id="67">build</g> fails with <g class="gr_ gr_117 gr-alert gr_gramm gr_inline_cards gr_run_anim Grammar only-ins replaceWithoutSep" data-gr-id="117" id="117">following</g> error can any <g class="gr_ gr_111 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" data-gr-id="111" id="111">ony</g> 1 help me

 MSBUILD : error MSB1021: Cannot create an instance of the logger. Could not load file or assembly 'file://\\localhost\ARM-Drop1\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.0.45\ps_modules\MSBuildHelpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll' or one of its dependencies. The system cannot find the file specified.
2018-12-28T14:48:31.5756456Z Switch: CentralLogger,\\localhost\ARM-Drop1\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.0.45\ps_modules\MSBuildHelpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll;RootDetailId=5a2f0936-7f91-4a8e-82e9-8efac2eea907|SolutionDir=\\localhost\ARM-Drop1\1\s
2018-12-28T14:48:31.6736652Z ##[error]Process 'msbuild.exe' exited with code '1'.

How to restore nuget packages when using MSBuild command line?

$
0
0

I'm using Visual Studio 2015 Update 1 and nuget 3.3.0.167, and I want to use MSBuild command line to build my solution. but it does not automatically restore nuget packages. i'm not using TFS or VSO, i just want to use command line to make an old build script work correctly.

i found some blogs for this, but they all need a folder called .nuget. but i don't have such a folder when creating solution by VS 2015.

thanks

How to select Device family and API contract?

$
0
0

I want to create New Hamburger Menu. But when I add NavigationView in XAML, it says "NavigationView is not supported in a Windows Universal project." 


Searched online and found that it needs some requirements. 


How can I meet these requirements? 

I am using Visual Studio 2015 and MS Windows Version 1809 (OS Build 19963.195)

'error MSB6006: "cmd.exe" exited with code 1. [C:\node-v11.6.0\rename_node_bin_win.vcxproj]'

$
0
0

When trying to build Node.js version 11.6.0 after downloading the source code from the Node.js website, and when it tried to build rename_node_bin_win.vcxproj, it failed with the error mentioned in the title.  The full message I got when it failed building that project is as follows:

"

rename_node_bin_win
  'mv' is not recognized as an internal or external command,
  operable program or batch file.
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(209,
5): error MSB6006: "cmd.exe" exited with code 1. [C:\node-v11.6.0\rename_node_bin_win.vcxproj]

"

Microsoft.CppCommon.targets line 209 is referring to this:

<CustomBuild
      Sources                     ="@(CustomBuild)"
      BuildSuffix                 ="$(_BuildSuffix)"

      TrackerLogDirectory         ="%(CustomBuild.TrackerLogDirectory)"
      MinimalRebuildFromTracking  ="%(CustomBuild.MinimalRebuildFromTracking)"

      TLogReadFiles               ="@(CustomBuildTLogReadFiles)"
      TLogWriteFiles              ="@(CustomBuildTLogWriteFiles)"
      TrackFileAccess             ="$(TrackFileAccess)"
      ToolArchitecture            ="$(CustomBuildToolArchitecture)"
      TrackerFrameworkPath        ="$(CustomBuildTrackerFrameworkPath)"
      TrackerSdkPath              ="$(CustomBuildTrackerSdkPath)"

      AcceptableNonZeroExitCodes  ="%(CustomBuild.AcceptableNonZeroExitCodes)"></CustomBuild>

 Any help would be greatly appreciated.  Thanks in advance.


Hiding pointer to function in CMFCPropertyGridProperty

$
0
0

I put the extra value in CMFCPropertyGridProperty (dwData, GetData()/ SetData()) to work storing the function pointer back to the getter/setter to which it applies. I've had luck storing it like this:

[CSettings]
typedef  void *(CHermesSettings::*GetSet)(void *);
[/CSettings]

[PropertySettings]
CMFCPropertyGridProperty *tmp = new CMFCPropertyGridProperty(_T("Auto open Mail Detail"), (_variant_t)pSettings->m_bAutoOpenAddressInfo, _T("Open Mail Detail on document open."));
GetSet f = &CHermesSettings::SetAutoOpenMailDetail;
DWORD_PTR ptr = (DWORD_PTR)&f;
TRACE(_T("[GetData=%lu]"), (DWORD)tmp->GetData());
TRACE(_T("[ptr=%lu]"), (DWORD)ptr);
tmp->SetData(ptr);

pGroupGeneral->AddSubItem(tmp);
[/PropertySettings]

Pulling it out again.. not so mcuh:

[PropertySettings]
LRESULT CPropertiesWnd::OnPropertyChanged(WPARAM wParam, LPARAM lParam)
{
	TRACE("LRESULT CPropertiesWnd::OnPropertyChanged(WPARAM wParam, LPARAM lParam) >>\n");


	// Parameters:
	// [in] wParam: the control ID of the CMFCPropertyGridCtrl that changed.
	// [in] lParam: pointer to the CMFCPropertyGridProperty that changed.

	// Return value:
	// Not used.

	// Cast the lparam to a property.
	CMFCPropertyGridProperty * pProperty = (CMFCPropertyGridProperty *)lParam;
	DWORD_PTR p = pProperty->GetData();
	DWORD_PTR ptr = (DWORD_PTR)&p;

	//GetSet s = p;


	TRACE(_T("[HIERACHYLEVEL=%d][NAME=%s][VALUE=%s][DATA=%lu]\n"), pProperty->GetHierarchyLevel(), pProperty->GetName(), (pProperty->GetValue() ? _T("TRUE") : _T("FALSE")), pProperty->GetValue());
[/PropertySettings]

Any ideas? It´s those pesky member pointers. I seem to remember reading quite a lot of it but it  obviously never stuck.


Turn off MSBuild Warning MSB8051

$
0
0

After much effort, we have only very recently got our build warning count down to a nice 0.  However recently, Microsoft added a new one for us.

"warning MSB8051: Support for targeting Windows XP is deprecated and will not be present in future releases of Visual Studio. Please see https://go.microsoft.com/fwlink/?linkid=2023588 for more information."

How to get rid?

(we have to still support XPEmbedded until next year, when Microsoft stop supporting it, so switching toolchain is not currently an option)

Migration of code with History in TFS 2017 Update 3

$
0
0

Hi All,

I have upgraded TFS 2015 to TFS 2017 update 3. For some requirement we moved a folder x from Project A (TFVC) to Project B(TFVC), folder x is in the form of Git repository. There is option to move history of 180 days only, is there any option or any extension to move the entire code with history.

And also the folder x before moving was (TFVC) from project A, after moving it is automatically converted to Git repository, is there any way or any extension to convert it back to TFVC.

I couldn't find the exact portal to post the question, so can anyone please move this question to right path for resolution.

Thank you in advance.

Regards,

Sumana

MSB4057: The target "RazorCoreGenerate" does not exist in the project.

$
0
0

asp.net core 2.2

Created new app with: donet new mvc

build with: dotnet buld

get: MSB4057: The target "RazorCoreGenerate" does not exist in the project

How to pack the products from multiple projects into one nuget without any nuspec file?

$
0
0

I am using Sdk projects targeting .NET Framework 4.7.2. The project structure is:

SmokeTests
 |
 +--UITests
 |   |
 |   +--Common
 |
 + NonUITests
     |
     +--Common

where:

  • the SmokeTests project references both UITests and NonUITests using ProjectReferences
  • UITests and NonUITests both reference Common using a ProjectReference
  • UITests, NonUITests and Common reference some NuGet packages using PackageReferences
  • the SmokeTests project has no source code, but it does have some content files.

I use the SmokeTests project as a roll up project. When I build it, its bin\debug\net472 directory contains all the binaries and symbols I want to have in the nuget package, i.e.:

  • The NuGet dependencies of UITests, NonUITests and Common
  • The dlls of UITests, NonUITests and Common
  • The PDBs

The SmokeTests csproj looks like this:

<Project Sdk="Microsoft.NET.Sdk"><PropertyGroup><TargetFramework>net472</TargetFramework><PackageId>SmokeTests</PackageId><NoPackageAnalysis>true</NoPackageAnalysis><IncludeBuildOutput>true</IncludeBuildOutput><GeneratePackageOnBuild>true</GeneratePackageOnBuild><ContentTargetFolders>content</ContentTargetFolders></PropertyGroup><ItemGroup><Content Include="**\*.ps1" Exclude="PSTests\run.ps1" /></ItemGroup><ItemGroup><ProjectReference Include="..\NonUITests\NonUITests.csproj" /><ProjectReference Include="..\UITests\UITests.csproj" /></ItemGroup></Project>


I also have a Directory.Build.props file:

<Project><PropertyGroup><TreatWarningsAsErrors>true</TreatWarningsAsErrors><AllowedReferenceRelatedFileExtensions>.pdb</AllowedReferenceRelatedFileExtensions><Version>$([System.Text.RegularExpressions.Regex]::Match($(BuildName), `\d+\.\d+(?:.\d+)?(?:.\d+)?`))</Version><Version Condition="'$(Version)' == ''">1.0.0.0</Version><SourceRevisionId>$(Revision)</SourceRevisionId><Company>My Company, Inc.</Company><Copyright>Copyright © $([System.DateTime]::Now.Year) by My Company, Inc. All rights reserved.</Copyright><Product>Smoke Tests</Product><NeutralLanguage>en-US</NeutralLanguage></PropertyGroup></Project>

When I build the solution, the produced SmokeTests.1.0.0.nupkg file does not contain any of the binaries, except the SmokeTests.dll itself. Clearly not what I want.

How can I get everything from bin\debug\net472 into the produced NuGet package **without specifying a nuspec file**? 

I can always hack an after build step that would manipulate the nupkg file, but I want a proper way to do it.

The question is also asked here - https://stackoverflow.com/questions/53625112/how-to-pack-the-products-from-multiple-projects-into-one-nuget-without-any-nuspe


Viewing all 2763 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>