Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jan 31 2019 22:54

    rainersigwald on vsix-depend-on-nuget

    VSIX dependency on NuGet.BuildT… Disambiguate branch name (compare)

  • Jan 31 2019 22:45
    livarcocc review_requested #4121
  • Jan 31 2019 22:45
    livarcocc review_requested #4121
  • Jan 31 2019 22:45
    livarcocc opened #4121
  • Jan 31 2019 22:42
    daryllabar commented #545
  • Jan 31 2019 21:40
    JL2210 edited #4116
  • Jan 31 2019 21:40
    JL2210 edited #4116
  • Jan 31 2019 21:39
    JL2210 commented #4116
  • Jan 31 2019 21:05
    livarcocc milestoned #4116
  • Jan 31 2019 21:05
    livarcocc commented #4116
  • Jan 31 2019 20:55
    rainersigwald milestoned #4120
  • Jan 31 2019 20:55
    rainersigwald demilestoned #4120
  • Jan 31 2019 20:53
    livarcocc synchronize #4115
  • Jan 31 2019 20:53

    livarcocc on vs16.0

    Bump version to disambiguate wi… Merge pull request #4119 from r… (compare)

  • Jan 31 2019 20:53
    livarcocc closed #4119
  • Jan 31 2019 20:50

    livarcocc on livarcocc-patch-1

    (compare)

  • Jan 31 2019 20:50

    livarcocc on vs16.0

    Adding a vs16.0 trigger Updating to a more general trig… Merge pull request #4118 from M… (compare)

  • Jan 31 2019 20:50
    livarcocc synchronize #4115
  • Jan 31 2019 20:50
    livarcocc closed #4118
  • Jan 31 2019 20:46
    livarcocc milestoned #4120
erikljung
@erikljung
(or any hack that could solve that)
Gregory Pakosz
@gpakosz

Hello. First time here.
I'm discovering the ReadLinesFromFile task

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Target Name="Build">
    <ReadLinesFromFile
        File="C:\config.txt" >
        <Output
            TaskParameter="Lines"
            ItemName="config"/>
    </ReadLinesFromFile>
    <Message Text="@(config)" />
  </Target>
</Project>

The config.txt file looks like this

foo=true
bar=false

I have 2 questions
• Is it possible to use Condition in the <Output> element to keep only lines matching a pattern?
• Knowing that my config file is named of key=value lines, is it possible to dynamically populate properties from the resulting config item?

Gregory Pakosz
@gpakosz

I can do

    <ItemGroup>
      <config2 Include="@(config)"
              Condition="$([System.Text.RegularExpressions.Regex]::IsMatch('%(Identity)', 'foo'))"
              />
    </ItemGroup>

But when I try

    <ReadLinesFromFile
        File="C:\config.txt" >
        <Output
            TaskParameter="Lines"
            Condition="$([System.Text.RegularExpressions.Regex]::IsMatch('%(Identity)', 'foo'))"
            ItemName="config"/>
    </ReadLinesFromFile>

msbuildcomplains with error MSB4095: The item metadata %(Identity) is being referenced without an item name

Michael W Powell
@mwpowellhtx
@gpakosz not 100% certain, but I am 92.6% positive that Condition occurs before <Output ... /> in this case, with a config variable receiving that output. So there is not enough information to do the %(Identity) step; IOW, Identity of what?
Try wrapping that in a <Target /> and reporting what that config %(Identity) was, perhaps.
Gregory Pakosz
@gpakosz

So I managed to write this

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Target Name="ReadConfig" BeforeTargets="Build"> 
    <ReadLinesFromFile
        File="C:\config.txt" >
        <Output
            TaskParameter="Lines"
            ItemName="ConfigFile"/>
    </ReadLinesFromFile>
    <ItemGroup>
      <Config Include="@(ConfigFile)" Condition="$([System.Text.RegularExpressions.Regex]::IsMatch('%(Identity)', '\w+\s*=\s*\w+'))">
        <Key>$([System.String]::Copy('%(ConfigFile.Identity)').Split('=')[0])</Key>
        <Value>$([System.String]::Copy('%(ConfigFile.Identity)').Split('=')[1])</Value>
      </Config>
    </ItemGroup>

    <CreateProperty Value="%(Config.Value)">
      <Output TaskParameter="Value" PropertyName="Foo" Condition="'%(Config.Key)' == 'foo'"/>
    </CreateProperty>
    <Message Text="[ReadConfig] ConfigFile: @(ConfigFile)" />
    <Message Text="[ReadConfig] Foo : $(Foo)" />
    <Message Text="[ReadConfig] Foo enabled" Condition="$(Foo)"/>
  </Target>

  <Target Name="Build">
    <Message Text="[Build] ConfigFile: @(ConfigFile)" />
    <Message Text="[Build] Foo : $(Foo)" />
    <Message Text="[Build] Foo enabled" Condition="$(Foo)"/>
  </Target>
</Project>

Still with config.txt file containing

foo=true
bar=false
Gregory Pakosz
@gpakosz
Now I'm trying to move that to a Visual Studio project and include a property sheet based on $(Foo)
Gregory Pakosz
@gpakosz
Right it seems I can't use that approach at all. As property sheets import is evaluated before tasks even run
Ivan Sanz Carasa
@isc30
Hi, I'm having difficulties implementing a custom MsBuild task when using net5.0 as TargetFramework
https://github.com/isc30/custom-msbuild-task
created that repository that reproduces the issue
Severity    Code    Description    Project    File    Line    Suppression State
Error    MSB4018    The "TestTask" task failed unexpectedly.
System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
File name: 'System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
   at CustomTask.TestTask.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
    TaskConsumer    E:\projects\custom-msbuild-task\TaskConsumer\TaskConsumer.csproj    13
Ivan Sanz Carasa
@isc30
Érico Vieira Porto
@ericoporto
I have a CLR/C++ code that is using /Z4p that builds fine on my VS2019 install but it gives me an error when I build it in a container that has the command line tools of VS2019 installed.

C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um\winnt.h(2483): error C2338: Windows headers require the default packing option. Changing this can lead to memory corruption. This diagnostic can be disabled by building with WINDOWS_IGNORE_PACKING_MISMATCH defined. [C:\Users\ContainerAdministrator\AppData\Local\Temp\cirrus-ci-build\Editor\AGS.Native\NativeDLL.vcxproj]
(last line is specific to my project and can be ignored)
The only difference I was able to pick is slight different cl.exe
In the container, cl.exe is Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24210 for x86
In my machine, cl.exe is Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24245 for x86
Érico Vieira Porto
@ericoporto
In the documentation says CLR won't respect alignment so I am not sure if there was a default change (https://docs.microsoft.com/en-us/cpp/dotnet/how-to-migrate-to-clr?view=msvc-160)
Érico Vieira Porto
@ericoporto
At same time "The headers aren't affected by any /Zp option you set on the command line" (https://docs.microsoft.com/en-us/cpp/build/reference/zp-struct-member-alignment?view=msvc-160) which makes it more weird because if it's not on the command line, where would be the alignment change?
Jerome Haltom
@wasabii
Hey folks. Trying to figure out the proper wya to include a DLL into a MSBuild file (SDK-style). Just adding it to ContentWithTargetPath isn't ensuring it ends up referenced in the .deps.json file. I'm sure there's some metadata for that though.
A native DLL. Packed into runtimes/rid/native
Dan Vicarel
@Rabadash8820
Hi friends. I would like to call Environment.GetFolderPath in a property function, with the following line <UnityInstallRoot>$([System.Environment]::GetFolderPath([System.Environment]::SpecialFolder::UserProfile))/Unity/Hub/Editor/</UnityInstallRoot>, but VS is showing a pop-up error with Invalid static method invocation syntax. It looks like this question has been asked before, but that was back in 2017, so I'm curious if the answer has changed. Am I missing something obvious in this syntax?
Bill Hertzing
@BillHertzing
Hi folks, I'm trying to move my code development from Visual Studio 2019 (VS) to Visual Studio Code (VSC). I'm currently stuck on creating the .resources and strongly typed files (for c#, .cs) from the .resx files. VS had plenty of built-in tooling to support this; in particular it has ResXFileCodeGenerator and PublicResXFileCodeGenerator to generate the strongly typed class from the .resx file, and it would add MSBuild code to the .csproj file to generate and embed the .resource files into the assembly being built. However, I can't find much on the internet on how to do this in the VSC editor. I've done a couple days of searching, and have found some explanations involving GenerateResource task, but no complete examples.
I'd like to know how to add, to the Directory.Build.props, and Directory.Build.targets files, the correct MSBuild properties, items, itemlists, tasks, and targets, that will 1) find all .resx files (both default and culture-specific) under any subdir under the project directory under the solution directory, create a public strongly-typed .cs file and ensure the project is recompiled if the .resx (and hence the .cs) changes, creates the .resource files from the .resx file (for both the default resources and any culture specific resources found), embeds the default culture .resource files into the assembly, and creates the satellite assemblies for any culture-specific .resource files. I'm using MSBuild 16.8.0+126527ff1 for .NET, multiple target frameworks <TargetFrameworks>netstandard2.1;net5.0</TargetFrameworks>, .csproj files are in the new SDK format, and I'm using the latest version of VSC. I've spent two days trying a lot of different things, and I'm actually pretty close (using GenerateResource task), but have hit enough pain points (can't seem to get it to accept task batching when also generating strongly-typed .cs files), that I thought I'd ask here if there already exists a solution, before I keep trying to build one of my own. Thanks in advance for any help!
Bill Hertzing
@BillHertzing
@Rabadash8820 I believe that MSBuild accesses static methods from .Net classes using the same syntax as Powershell. I felt it might be true for enumerations from .Net classes as well. Doing some experimentation in PowerShell, I found that, from a PowerShell prompt, that entering[System.Environment]::GetFolderPath([System.Environment+SpecialFolder]::UserProfile) would display my UserProfile. You might try that syntax for your issue. plus-in-net-class-names has a little bit more detail.
Jerry Wiltse
@solvingj
When writing a custom task in MSBuild, is there any way to access "current configuration" when the task is executed (Win32|Debug for example). I honestly can't seem to find a way to do it without having to add Configuration and Platform parameters to my build task, and there's no way that's required right? I'm crawling every namespace here and I feel like it must be there but I can't find it: https://docs.microsoft.com/en-us/dotnet/api/?view=msbuild-16-netcore
Dan Vicarel
@Rabadash8820
@BillHertzing thanks for the reply! That pointed in me in the right direction. MSBuild seems to be using some weird "almost PowerShell" syntax. In the end, this expression worked in my MSBuild property: $([System.Environment]::GetFolderPath('System.Environment+SpecialFolder.UserProfile')) (note the simplified enum member name with single quotes around it)
Dylan Borg
@borgdylan
@radical Is the monof ork of msbuild still worked on? Or is there a migration path to use the .NET SDK version for desktop frameework or mono projects also?
Jose
@pepone
Hey I creating some items in a target with an ItemGroup
<ItemGroup>
            <ClCompile Include="@(_SliceCompile->'%(OutputDir)\%(Filename).%(SourceExt)')"
                       Exclude="@(ClCompile->'%(FullPath)');@(ClCompile->'%(Identity)')" />
        </ItemGroup>
But I would expect the new ClCompile to no inherit any metadata from the _SliceCompile item, but I seeing it is copying the AdditionalOptions,
Jose
@pepone
is there some metadata inheritance for the items generated inside a target?
Jose
@pepone
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="SliceCompile" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemDefinitionGroup>
    <SliceCompile>
        <AdditionalOptions>--add-header foo.h</AdditionalOptions>
    </SliceCompile>
</ItemDefinitionGroup>
<ItemGroup>
    <SliceCompile Include="Foo.ice">
        <AdditionalOptions>%(AdditionalOptions) --other</AdditionalOptions>
    </SliceCompile>
</ItemGroup>
<Target Name="SliceCompile">
    <ItemGroup>
        <ClCompile Include="@(SliceCompile->'%(Filename).cpp')">
        </ClCompile>
    </ItemGroup>
    <Warning Text="@(ClCompile->'%(ClCompile.Identity) %(ClCompile.AdditionalOptions)'"/>
</Target>
</Project>
Here the ClCompile generated item has all the metadata from SliceCompile, any pointers as to why this happens
Chris McGrath
@clmcgrath

not sure where to put this

having an odd issue with msbuild vscode and visual studio all failing and not able to find critical pieces of .netcore 3.1 / .net 5
i have reinstalled 4x and also tried manually installing from the binary package all of which are failing , it started with not finding the sdk at all , the binary package manual install semms to have fixed that issue but now i am recieving errors about not being able to find the netcoreapp targeting pack , this is happening in all products and the cli as well

Christian Seidlitz
@SeidChr

hi there

anyone has an idea how i could exclude a referenced analyzer package in a normal "dotnet build" command, but include it in the roslyn compiler stuff whick is used to generate the warnings and hints in vscode (probably called by omnisharp)
is there any environment variable i can check which is set during a normal build and not set on the others?

Bill Hertzing
@BillHertzing
@SeidChr I believe you are referring to the difference between "normal" builds and "Design-time builds". Here's a link to more information about Design-time builds under Visual Studio. I also spent a few minutes seeing if the same would work under Visual Studio Code (Omnisharp), however, I was not successful, mainly because I couldn't find any Omnisharp logs that would hopefully show every time Omnisharp kicks off any Design-time builds. For what its worth, I hope this helps you. Would love to know if you get it figured out for VSC.
plsHelpMe-vs
@plsHelpMe-vs
How am I gonna solve the CopyRefAssembly task failed unexpectedly?
Igor Velikorossov
@RussKie
Use binlogs and https://msbuildlog.com/
Dylan Borg
@borgdylan
@radical Is MSBuild 16.8 and 16.9 planned for Mono?
Francesco Pretto
@ceztko
Hello, is it possible to configure binlog when compiling projects using MSBuildWorkSpace?
Francesco Pretto
@ceztko
MSBuild maintainers advised me to do so in this issue, but there's no example of how to do it, nor the MSBuildWorkSpace seems to be expressive enough to allow to do it trivially, so I'm out of ideas
Tebjan Halm
@tebjan
is it possible to bundle MSBuild with an application? So the end-user doesn't need to install it. basically setup a local MSBuild environment next to the exe and use that instead of relying on it to be installed on the system.
the reason is, almost every MSBuild update breaks our app and install process, which is an absolute pain for the end-user and us as developers.
Keith Rosenberg
@netpoetica

Has anybody encountered this error before?

Project "C:\build\plugins-example\build\ALL_BUILD.vcxproj" on node 1 (default targets).
C:\BuildTools\MSBuild\Microsoft\VC\v160\Microsoft.Cpp.props(31,5): error MSB4186: Invalid static method inv
ocation syntax: "[Microsoft.Build.Utilities.ToolLocationHelper]::FindRootFolderWhereAllFilesExist($(_VCTarg
etsPathFolders), $(_RelativeToolsetFiles))". Method 'Microsoft.Build.Utilities.ToolLocationHelper.FindRootF
olderWhereAllFilesExist' not found. Static method invocation should be of the form: $([FullTypeName]::Metho
d()), e.g. $([System.IO.Path]::Combine(`a`, `b`)).  [C:\build\plugins-example\build\ALL_BUILD.vcxproj]
Done Building Project "C:\build\plugins-example\build\ALL_BUILD.vcxproj" (default targets) -- FAILED.

I am generating these projects with CMake using vcpkg toolchain:

cmake -G "Visual Studio 16 2019" -A x64 ../ -DCMAKE_TOOLCHAIN_FILE=$CMAKE_TOOLCHAIN_FILE

I have been struggling for a while to find any illuminating ideas as to what it means on the web :) hoping it is something simpler than I think

Jacob Hodges
@jachin84
I am trying to understand the relationship between VSTest target and the vstest.console.exe
It looks like VSTest eventually calls vstest.console.exe.
But does so once per test assembly rather than passing in all tests in one go.
Adam Granicz
@granicz
Hi all - newbie question, sorry if it has been asked before: is there an msbuild command that I can run in a folder with a project file that gives me the full list of resolved assemblies (free of package/project references)?
Oleksii Kavka
@Varveyn
Hello everyone. As far as I see, it is supported to specify the Version for the PackageReference as a child tag rather than an attribute. But there's no IntelliSense support for this in Visual Studio (2019) and the documentation does not mention that the version can be specified like this. Is such syntax discouraged?
<PackageReference Include="Castle.Windsor">
  <Version>5.1.1</Version>
</PackageReference>
Bert Huijben
@rhuijben
@Varveyn MSBuild's syntax parser usually allows both syntaxes, but xml intellisense has no easy way to declare both at once...