1

I built two quick programs today. The one I'm showing here is just a quick program that will change the date of a virtual machine to a specific date. I've tested it and deployed it, but to no avail I cannot get it working on another machine. I've double checked my work by following this documentation. Both PC's are running .NET 4.7. I'm not sure what the problem is. Any help is appreciated!

The error:

Error: assembly specified in the dependencies manifest was not found -- package: 'microsoft.codeanalysis.common', version: '1.3.0', path: 'lib/netstandard1.3/Microsoft.CodeAnalysis.dll'

Project.cs

using System; 
using System.IO; 
using System.Runtime.InteropServices; 
using System.Windows;

namespace vmRedundancy {

class Program {

    public struct SYSTEMTIME {
        public ushort wYear, wMonth, wDayOfWeek, wDay,
        wHour, wMinute, wSecond, wMilliseconds;
    }
    /// <param name="lpSystemTime">[out]</param>
    [DllImport ("kernel32.dll")]
    public extern static void GetSystemTime (ref SYSTEMTIME lpSystemTime);
    /// <param name="lpSystemTime">[in]</param>
    [DllImport ("kernel32.dll")]
    public extern static uint SetSystemTime (ref SYSTEMTIME lpSystemTime);

    static void Main (string[] args) {
        SYSTEMTIME st = new SYSTEMTIME();
        GetSystemTime(ref st);
        Console.WriteLine("The date was: " + st.wMonth + @"\" + st.wDay + @"\" + st.wYear); 
        st.wDay = 1;
        st.wMonth = 6;
        st.wYear = 2017;
        SetSystemTime(ref st);
        Console.WriteLine("The date is: " + st.wMonth + @"\" + st.wDay + @"\" + st.wYear); 
        //Console.WriteLine("The day of the week is: " + st.wDayOfWeek); 4
        Console.WriteLine("The time is: " + (st.wHour - 4) + ":" + st.wMinute + ":" + st.wSecond + " " + st.wMilliseconds + "ms"); 
            Console.ReadKey();
        }
    }
}

ChangeDateTime.json

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <RuntimeIdentifiers>win7-x64;win10-x64</RuntimeIdentifiers>
    <TargetFramework>netcoreapp1.1</TargetFramework>
  </PropertyGroup>

</Project>

**The Publish: **

dotnet publish -r win7-x64

dotnet --info (deployment)

.NET Command Line Tools (1.0.4)

Product Information:
Version: 1.0.4
Commit SHA-1 hash: af1e6684fd

Runtime Environment:
OS Name: Windows
OS Version: 10.0.15063 OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\1.0.4

dotnet --info (client)

.NET Command Line Tools (1.0.4)

Product Information:
Version: 1.0.4
Commit SHA-1 hash: af1e6684fd

Runtime Environment:
OS Name: Windows
OS Version: 6.1.7601
OS Platform: Windows
RID: win7-x64
Base Path: C:\Program Files\dotnet\sdk\1.0.4

addohm
  • 2,248
  • 3
  • 14
  • 40
  • 1
    According to the error, you're not including all the DLLs required by the binary. – Adrian Jun 01 '17 at 21:18
  • Check this out: https://stackoverflow.com/questions/42536506/could-not-load-file-or-assembly-microsoft-codeanalysis-version-1-3-1-0-cultu – JuanR Jun 01 '17 at 21:30
  • @Juan this applies to Visual Studio IDE. I'm building and publishing with the dotnet console compiler. – addohm Jun 01 '17 at 21:41
  • I understand that, but the issue is still the same. You are missing a library (as illustrated in the link) so I was hoping that could help you figure out why it's missing. – JuanR Jun 02 '17 at 14:03

1 Answers1

0

I was able to make this work by downloading and installing the .NET 4.7 SDK and changing everything to suit. Seems weird that "core" compiled items don't work across different platforms. I am sure I am misunderstanding something; I just don't know what!

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <RuntimeIdentifiers>win7-x64</RuntimeIdentifiers>
    <TargetFramework>net47</TargetFramework>
  </PropertyGroup>

</Project>
addohm
  • 2,248
  • 3
  • 14
  • 40